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
Developing flask backend

Hey guys, hope y'all are doing well.
I'm developing a flask backend to run a segformer and an stable diffusion model. I got both of them off of hugging face. I tested everything out in Jupiter and they work fine.
My tech stack is currently a next/reactjs frontend, SupaBase for auth etc, stripe for payments and flask as an API to provide the key functionality of the AI.
I'm getting started with the flask backend, and although I've used it in the past, this is the first time I'm using it for a production backend. So, logically, my questions are:

-Do I need to do something for multi threading so that it can support multiple users' requests at the same time?

-Do I need to add something for token verification etc.

-Which remote server service provides good GPUs for the segformer and stable diffusion to run properly?

-Any other key things to look out for to avoid rookie mistakes would be greatly appreciated.

I already installed waitress for the deployment etc and I was wondering whether I should dockerize it too after it's developed.

/r/flask
https://redd.it/1f6nwxt
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1f6syvh
Table goes blank when page is refreshed...

shows is a list of lists being passed to the HTML file used to populate a table. When I run the program and open the page for the first time, the table populates just like it's supposed to. But if I refresh the page in the browser, the table goes blank except for the headers. Why is this happening?

from flask import Flask, rendertemplate
from getshows import get
shows
import pandas as pd
from time import sleep


filename = "Output.csv"
df = pd.read
csv("ListedVenues.csv")
# create an empty dictionary to hold the show information
shows
tonight = {
"venue": ,
"show": ,
"date": ,
}
# make the API calls to get show information and store it in the showstonight dictionary
for index, row in df.iterrows():
venue, bands, date = get
shows(row"Venue

/r/flask
[https://redd.it/1f6spgz
Hey, I’m new to Flask and have a question. When I have a flask server running the URL never works and always says ‘Not found’ even though its running. Any help?



/r/flask
https://redd.it/1f6jhh3
Something really really weird happens...

So my base template is (deleted link to the CSS spreadsheet due to debugging):

https://preview.redd.it/mwpy7k4r29md1.png?width=422&format=png&auto=webp&s=3adfe342a4ff8fc77b3c3eb71ffcc08950e67224

https://preview.redd.it/d0oyqtj139md1.png?width=708&format=png&auto=webp&s=74e061b7cab2a7e49053f33e00d5732f1b5f5dc5

https://preview.redd.it/5awcger739md1.png?width=708&format=png&auto=webp&s=f23df724d6f3c88dfc96ffe69f194febef3e162e

\^ And then I have this template with internal CSS. And when I extend it (pic 2), it doesn't render at all. When I write a text to these divs, they only expand to the point to accomodate that text.


But when I'm not extending it (3), then it renders fine, like it's supposed to render.

Anyone?

/r/django
https://redd.it/1f6n2p2
IAAS or similar cloud computing service to deploy a MVP

Hi everyone, I'm developing a MVP software product and I'm looking for the best option relation between freemium and features. Thanks

/r/django
https://redd.it/1f6t3x0
Django Course or Book

hi guys . i'm new to django framework after i learned the basics of python and DSA , now i need a friendly beginner course or book not just to teach me how to use this feature in django but why i need it and thanks.

/r/django
https://redd.it/1f72eg1
Looking to Collaborate on Django Projects or Start Something New

Hey everyone!

I’ve completed a few Django projects, including a library system, blog platform, and a face and plate recognition attendance app using RabbitMQ. I’m experienced with Django, Celery, RabbitMQ, and both relational and non-relational databases.

I’m looking to collaborate on new projects to strengthen my GitHub portfolio. If you have any project ideas, need an extra hand on existing projects, or want to brainstorm something cool, let’s connect!

Thanks!

/r/django
https://redd.it/1f748vp
Can anyone help me complete my tracker server (BitTorrent Protocol)

I am trying to create my own private bittorrent protocol which I will use for load balancing static data in the web server to visitors. I have app.py written, among other things, but what is weird to me is that I can initiate the magnet url download process, but then no data is transferred. Additionally, I am able to download .torrent files.


This is the repository, could someone take a look at it and tell me what they think? I'm planning to make this a free and public web forum.

/r/flask
https://redd.it/1f79sre
Smartcut: Super fast cutting and trimming of videos

What My Project Does

Smartcut is to my knowledge the most robust open-source implementation of frame accurate video cutting without recoding, a.k.a smart cut, smart encoding, smart render, etc.

It uses PyAV and libavcodec (ffmpeg internals) to encode a small part of the video near the cutpoints and then uses libavformat to stitch the recoded segments and parts of the original video back together into a whole video.

https://github.com/skeskinen/smartcut

Target Audience

This project is for people who want to cut videos really fast from the command line. This could be useful e.g. as part of a script that goes through a directory and quickly cuts off some part of the videos. It could also be used as a part of a video editor project, like I've done in my GUI video editor project.

It is also one of the largest available projects that uses PyAV (the pythonic bindings for libav project) and really showcases the awesomeness of the library. I also contributed 4 patches to PyAV and the maintainer was really cool to work with.

Comparison

The github page has a pretty nice list of related projects: https://github.com/skeskinen/smartcut?tab=readme-ov-file#other-projects

The most obvious comparison is to lossless-cut which is a popular open-source video editor written in TypeScript and Electron

/r/Python
https://redd.it/1f767df
Is Django Still Relevant for Backend Jobs?

Hi Djangonauts!

I'm a junior CS student with some experience in Django (intermediate functionality, needs frontend work). While I enjoy using Django, I'm concerned about landing a job with it after graduation. Many postings seem to focus on C# and .NET

My questions are:

Is Django still a valuable skill to learn for backend development positions?
Would focusing on C# and .NET offer better job prospects, considering the current market?

My dilemma:

I'm unsure if I should continue building my Django skills or switch gears to C# and .NET for better job security.

I'm feeling some pressure to upskill and avoid the pitfalls of job seekers lacking the right skills.
so I'm trying hard and pushing through burnouts, trying to upskill in order to strengthen my capability and candidacy.

/r/django
https://redd.it/1f76jbk
Why not just get your plots in numpy?!

Seriously, that's the question!

Why not just have simple
plot1(values,size,title, scatter=True, pt_color, ...)->np.ndarray
function API that gives you your plot (parts like figure and grid, axis, labels, etc) as numpy arrays for you to overlay, mask, render, stretch, transform, etc how you need with your usual basic array/tensor operations at whatever location of the frame/canvas/memory you need?

Sample implementation: https://github.com/bedbad/justpyplot

# What my project does?

Just implements the function above

When I render it, it already beats matplotlib and not by a small margin and it's not the ideal yet:

Plotting itself done in vectorized approach and can be done right utilising the GPUs fully

plot1, plot2 .. plotN is just dependency dimensionality you're plotting (1D values, 2D, add more can add more if wanted)

Target Audience? What it Compares against?
Whoever needs real-time or composable or standalone plotting library or generally use and don't like performance of matplotlib [1, 2, 3\]

I use something similar thing based on that for all of my work plotting needs and proved to be useful in robotics where you have a physical feedback loop based on the dependency you're plotting when you manipulating it by hand such as steering the drone;


/r/Python
https://redd.it/1f7jfgd
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1f7lwin
pytest vs unittest?

I keep reading from Django’s official site to use unittest, but I’m reading more about pytest and find some aspects really interesting and intuitive. What does the community at large prefer?

/r/django
https://redd.it/1f7maoe
Anyone made the switch from ASP.NET Core?

I'm a .NET developer by daytrade, and I'm starting side projects from time to time. Usually it's been Node.js/Go/ASP.NET, but I've never done Django yet. I'm just not a big Python user in general.

However, it now looks like I have to build an admin panel by myself for a side project I've just started, and Django entered my mind as it's got one by default. It looks like Django + DRF is sort of a ASP.NET/Spring lite-edition, so I'm looking to see some feedback if anyone has actually moved from ASP.NET to Django, or just used both and have some feedback to share.

One thing I'm kind of suspicious about is the performance. ASP.NET is what, 10x faster than Django? However I know it probably won't make a real difference, but seems a shame if there is no real benefit to using Django.

/r/django
https://redd.it/1f7ezda
Web scraping with GPT-4o: powerful but expensive

Hey folks,

So I've been messing around with OpenAI's new structured outputs feature and decided to build an AI-powered web scraper. Thought I'd share some of the cool (and not so cool) stuff I found.

**The Good:**

* This thing can parse some pretty complex tables. I threw a 10-day weather forecast at it with all sorts of nested data, and it handled it like well.
* It's smart enough to figure out merged cells and hidden data in the HTML.

**The Bad:**

* Wikipedia tables with combined rows? Yeah, that broke it.
* Asking it to give XPaths directly was a mess. Had to do some workarounds.

**The Ugly:**

* GPT-4o is expensive! Spent $24 in two days just messing around.

I made a quick demo with Streamlit if anyone wants to check it out: [https://orange-resonance-9766.ploomberapp.io](https://orange-resonance-9766.ploomberapp.io)

Source code's on GitHub if you're curious: [https://github.com/edublancas/posts/tree/main/ai-web-scraping](https://github.com/edublancas/posts/tree/main/ai-web-scraping)

Anyone else played with AI for web scraping? What's been your experience?

P.S. If you want the full nerdy details, I wrote a blog post about it: [https://blancas.io/blog/ai-web-scraper/](https://blancas.io/blog/ai-web-scraper/)

/r/Python
https://redd.it/1f7g0t9
Looking for fellow learners

TLDR: If you are interested in learning and then building in Django, Please DM me and we can start ASAP. I am a beginner in Django.

I am looking for one to two people to learn and practice Django together. This way we all can learn faster and build something cool together.

Requirements:

Must be serious learners who want to learn quick and start building.

Must be proficient with programming in general and have decent knowledge of Python. Quick Learner and positive mindset.

Plus Points: If you are experienced.

About Me: I am a software Engineer proficient in C++ & Python, Strong knowledge of Programming & DSA. Have almost 2 YOE.

To people who have commented: I have zero experience with Django, know basic things like views, models, app, users, admin etc. but would like to start from square 1 which i think should take like a week to get done with basics and jump on to building. Just telling it so that you have clear idea about my Django Knowledge and what to expect.

/r/django
https://redd.it/1f7awk6
Deploying on Choreo.dev?

Hi Guys,

I am testing out different options for hosting my django + postgresql + react application. I found https://choreo.dev/ very convenient because i can manage all parts of the application on one dashboard instead of using 3 different providers.

However, it makes me a little suspicious that you can hardly find anything about choreo on the internet + the documentation is also not that extensive.

Do any of you have experience with the provider, and if so, what do you think?

/r/django
https://redd.it/1f7yhrx