Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Where to host Flask App

Hi everyone! I just developed my first flask app, and needed some assistance in getting it deployed as I've never done it before. My app uses multiple databases (SQLite currently) to keep track of events and participation for an organization I am in. I originally was going to use render since it was free but since it seems like it refreshes it won't be a good fit since it will wipe my dbs. I then looked at creating a PostgreSQL database on render but their free tier only lasts a month. If there is a way to host this for free I'd love to do that since the org is only about \~100 people and the website wouldn't be in use constantly and the likelihood of concurrent writes is very low. I was wondering if anyone knew a place where I could host this web app (hopefully for free), or for low cost if I can use SQLite as I'd rather not update everything atp. If anyone has any advice or helpful resources I'd greatly appreciate it!

/r/flask
https://redd.it/1hvz0ov
Different values in group by columns before and after group by in pandas dataframe

I had following code:

sum_columns = ['p', 'q', 'r', 'Ax', 'Ay', 'Az']
avg_columns = ['Bx', 'By', 'Bz', 'G2 C03']
agg_map = {col: 'sum' for col in sum_columns}
agg_map.update({col: 'mean' for col in avg_columns})

df = df.groupby(['MAC C01', 'MAC C02', 'MAC C03'], as_index=False).agg(agg_map)

Dataframe before group by:

```
p q r Ax Ay Az Bx By Bz G2 C03 MAC C01 MAC C02 MAC C03
0 0.0 0.0 0.1 0 0 0 0 0 0 0.0 0.00000 0.00000 0.0
1 0.0 0.1 0.1 0 0 0 0 0 0 0.0 0.00000 0.00000 0.0
2

/r/Python
https://redd.it/1hw24sf
Logic in Views vs Logic on Models

Hey folks,

Apparently this is a frequently discussed topic.

Im doing a project using DRF. In this context i feel like the Views that are basically APIs should have logic, but my approach so far was that whatever touches a model, goes in the model.

Concrete example: one of my APIs has to change the Status of a Sales order. Then i will create a method in the SalesOrder model that will do the status change, along with any particular validation that it might want to do (example if you're changing it to completed/closed, ensure theres no open amount and the items were delivered)

Can you give me your thoughts about this approach and if its worth moving everything to either the views or to another "business logic" layer (or both)?

I dont really have crazy calculations or bigass logic for anything in particular, but i rather learn the proper way


Looking online i see all kinds of recommendations, the logic layer as well as the Thick Models, as well as "Model is simply the ORM". So i feel like it doesnt really matter as long as its consistent and is useful for the individual project?

/r/django
https://redd.it/1hw5066
Full-Stack Software Job at RegTech Startup

🚀 We’re Hiring: Full-Stack Software Developer 🚀

RegMetrics is a regulatory compliance software for medical devices. Our mission is to simplify the regulatory journey, saving MedTech innovators and academics time and money while helping bring life-changing medical devices to market.

We’re looking for an experienced Python/Django developer with strong frontend skills to help us in our journey. If you know Wagtail, that's even better.

The job is fully remote but right now we can only hire from Brazil or UK.

If you're interested, please apply through our website

/r/django
https://redd.it/1hw2o2c
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1hw61sj
Open-Source & Free Django App Generator - Select Design, Edit DB Tables, Extended User Fields, Add Celery, Social Login (GitHub), Docker

Hello guys!

[App-Generator.dev](https://App-Generator.dev) service released a simple Django App Generator that might help to customize, generate, and download the code as a ZIP archive or from GitHub.



[https://app-generator.dev/tools/django-generator/](https://app-generator.dev/tools/django-generator/)



The users can customize:

* UI: AdminLTE, Soft Dashboard .. etc (10 designs)
* DB Driver: SQLite (default), PgSQ, MySql/MariaDB
* DB Tables - table relations supported
* Extended User Model
* (optional) Social Login: GitHub
* (optional) Celery - async tasks
* (optional) Dynamic API - each model can be managed via a secured DRF endpoint
* (optional) Docker
* (optional) Ci/CD scrips for Render

The generator code uses a combination of template code generation and Astor Library for AST manipulation - source code saved on GitHub as celery task



[https://github.com/app-generator/app-generator/blob/main/apps/tasks/tasks.py](https://github.com/app-generator/app-generator/blob/main/apps/tasks/tasks.py)



Currently, the tool generates around 20 apps/day and the code is automatically saved on GitHub:



[https://github.com/app-generator?tab=repositories](https://github.com/app-generator?tab=repositories)



In the long run, the plan is to integrate more OAuth providers, DataTables, and a visual page builder.

Thanks for feedback & suggestions.

/r/django
https://redd.it/1hwdqy3
D ML Engineers, what's the most annoying part of your job?

i just know a phd just inspecting datasets and that sounds super sad

/r/MachineLearning
https://redd.it/1hwbhuj
Need help hosting flask app

Hi,

I’m sure I’ll get hell for this as I often do, I’m an educator for a niche field and built a flask app with the help of ai, basically a flashcard tool to help me at my practice. App works great, no errors on the user side, now I want to host it so I can access it. Truth be told, I also want to share with others in my field.

I’m so frustrated with hosting, it’s true that ai led me down a road where I got lost, but it’s also true that I have a tool I couldn’t find anywhere else, a tool I’ve dreamed about since being in the field.

Any simple ways to get around this? Not opposed to fiverr, but I didn’t have great experience with them before. For the record I’ve tried PythonAnywhere, Heroku, and AWS and keep getting errors I cannot make sense of. I would LOVE to learn hosting so I could truly do it on my own, but tutorials go from “the back end talks to the front end” to “you need to configure the WSGI, route here route there” very quickly.

/r/flask
https://redd.it/1hwamy0
Flowkeeper -- a PySide6 (Python + Qt6) application

Greetings! Meet [Flowkeeper](https://flowkeeper.org/), a cross-platform desktop Pomodoro timer, which took me about a year to reach its current state. It is implemented in Python and relies on Qt6 for its UI. It supports recent macOS, Windows 10 and 11, and any mainstream Linux released within a couple of years, e.g. Ubuntu 22.04.

Feel free to reuse parts of it, or ask me any questions about how things are implemented.

# What My Project Does

It allows you plan your work for the day, and then execute it using Pomodoro Technique.

# Target Audience

Power users -- mainly creative professionals and students. Flowkeeper can be used in production and enterprise environments.

# Comparison

Compared to a typical Pomodoro timer, Flowkeeper:

* Implements Pomodoro Technique exactly as described in the [original book](https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.amherst.edu/system/files/media/Pomodoro%252520Guide_0.pdf&ved=2ahUKEwjNsqig_eWKAxW7U6QEHZQMA-8QFnoECAsQAQ&usg=AOvVaw20GKwRpyxshlCpBzcw7-40),
* Supports a wider range of desktop operating systems, including diverse Linux environments,
* Is more lightweight and performant (it's not based on Electron, and I routinely test it on a Core 2 Duo machine),
* Has portable versions and does not require admin rights to install,
* Is optimized for power users (keyboard shortcuts and rich set of settings),
* Does NOT have a paid version,
* Does NOT have a mobile version,
* Does NOT synchronize data across devices,
* Is NOT

/r/Python
https://redd.it/1hwhvns
Combining ThreadPoolExecutor and threading.Thread in the same python application

Is it okay to use both the threading.Thread and ThreadPoolExecutor class for managing tasks in application using threads. For example some part in the application using threading.Thread and other parts of the application using ThreadPoolExecutor. I think the latter will have its own thread pool and the former would create ad-hoc threads without using the thread pool.

/r/Python
https://redd.it/1hwk104
Help! Is there no LSP and auto completions in Python & Django?

I have a code base running on Python 3.10.
I have tried pylsp, pyright & ruff but the moment I try and use something Django, The auto completions doesn't exist.

Users.objects() ? No completions or LSP documentations. Is this normal for python?

I have tried Golang, NodeJS and even C. It gives me atleast something to work with. Even to know type of a variable, I need to print with type().

Just want to know if there's something that I can do to make things easier.

/r/django
https://redd.it/1hwlwrt
Learning Django before a job interview

A company just called me to do a job interview and I was told they work with Django.


I've already worked with Fastapi and Flask and everything I know from Django is what I did long time ago in an online course. They are already aware that I don't know but they wanted to have an interview anyway.


My plan is the following:
In one week I will try to make something in Django for them and show it, just to make a good impression, like someone who is interested in learning.

So I was thinking about something like using a third api (spotify, for example) inside django where I can throw some artist ids and get the information back through Django. Like an API working inside of the framework.


Do you have some tips?

/r/djangolearning
https://redd.it/1hwoiqo
RD What are the most important papers that provide entry to your domain of research?

Please mention what domain (niche) of machine learning you work in for your research?

Why did you chose that particular domain?

If someone with basic understanding of machine learning and deep learning wants to get involved in your field, which papers/blogs/tools should they consider reading/implementing?

/r/MachineLearning
https://redd.it/1hwkmwm
Python users, how did you move on from basics to more complex coding?

I am currently in college studying A level Computer science. We are currently taught C#, however I am still more interested in Python coding.

Because they won't teach us Python anymore, I don't really have a reliable website to build on my coding skills. The problem I am having is that I can do all the 'basics' that they teach you to do, but I cannot find a way to take the next step into preparation for something more practical.

Has anyone got any youtuber recommendations or websites to use because I have been searching and cannot fit something that is matching with my current level as it is all either too easy or too complex.

(I would also like more experience in Python as I aspire to do technology related degrees in the future)

Thank you ! :)

/r/Python
https://redd.it/1hwsv6i
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1hwz5go
Linkversity: My latest Flask pet project in prod (My hosting / deployment setup)

I coded linkversity.xyz. I think deploying Flask apps is easy. Since ive been seeing queries as to hosting and deployment, here is my setup:

My nginx conf

server {

listen 80;

server_name linkversity.xyz www.linkversity.xyz;

return 301 https://$host$request_uri;

}



server {

listen 443 ssl;

server_name linkversity.xyz www.linkversity.xyz;



# SSL Configuration

ssl_certificate /etc/letsencrypt/live/linkversity.xyz-0001/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/linkversity.xyz-0001/privkey.pem;



# SSL Protocols and Ciphers

ssl_protocols TLSv1.2 TLSv1.3;

ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';



ssl_protocols TLSv1.2 TLSv1.3;

ssl_prefer_server_ciphers on;

ssl_ecdh_curve auto; # Use auto to let OpenSSL select appropriate curves

ssl_session_cache shared:SSL:10m;

ssl_session_timeout 1d;

ssl_session_tickets off;



# Additional security headers

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

add_header X-Content-Type-Options nosniff;

add_header X-Frame-Options SAMEORIGIN;



location / {

proxy_pass http://127.0.0.1:5000;

proxy_set_header Host $host;

proxy_set_header X-Forwarded-User $remote_user;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_http_version 1.1;

proxy_read_timeout 300;

proxy_connect_timeout 300;

proxy_send_timeout 300;

# include proxy_params;

}



location /static/ {

alias /var/www/linkversity/static/;

}

location ~ /\.git {

deny all;

}

}

My gunicorn conf

[Unit]

Description=Gunicorn instance to serve Linkversity Flask application

After=network.target



[Service]

User=root

Group=www-data

WorkingDirectory=/root/code/linkversity

ExecStart=gunicorn -w 4 -b 0.0.0.0:5000 app:app \

--access-logfile /root/code/linkversity/logs/access.log \

--error-logfile /root/code/linkversity/logs/error.log

Restart=always

RestartSec=5

StartLimitBurst=5

StartLimitIntervalSec=60



[Install]

WantedBy=multi-user.target

And repo source

I am using a VPS from GalaxyGate.

I think a VPS is worth it, costs more than some sites but you do things your way.

Hopw it helps!



/r/flask
https://redd.it/1hw3i85
Arch Gateway - an open source intelligent gateway for AI agents - focus on business logic of agents

# What My Project Does

Arch is an intelligent Layer 7 gateway (proxy) designed to protect, observe, and personalize AI agents with your APIs. The project was born out of the belief that: Prompts are nuanced and opaque user requests, which require the same capabilities as traditional HTTP requests including secure handling, intelligent routing, robust observability, and integration with backend (API) systems for personalization - all outside business logic.

Check out the project here: https://github.com/katanemo/archgw Ask me anything.

# Target Audience

Meant to help developers building AI Agents in production with safety, observablity and personalization features needed for differentiation. Focus on the stuff that matters, not the crufty work to get agents into production.

# Comparison

Compared to NGINX, HAProxy, Envoy - Arch Gateway was designed for prompts. Engineered with purpose-built small LLMs, Arch handles the critical but undifferentiated tasks related to the handling and processing of prompts, including detecting and rejecting jailbreak attempts, intelligently calling "backend" APIs to fulfill the user's request represented in a prompt, routing to and offering disaster recovery between upstream LLMs, and managing the observability of prompts and LLM API calls - outside application code so that you can focus on what matters most


Compared to other proxies like Protkey,

/r/Python
https://redd.it/1hx0hz0