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
stripping variable rule in URL after request

hi, I've got a route called /shops/<shopId>/thumbnail, which obviously returns a image/png thumbnail of a certain shop. atop of that there is an after request handler, which adds some caching to the response. is there a way to strip the shopId from the route URL in the after request handler? (so it becomes /shops/<shopId>/thumbnail, instead of e.g. /shops/114/thumbnail)

/r/flask
https://redd.it/189rdoz
Need ideas Licencing/api key management

Basically I have developed an DL model,
I will be hosting it in client environment

I want to keep a track that client uses it on only 10k images(hypothetical number), if client process more than 10k than they have to pay extra charge ..


So I need to build an web api app..
Whenever my model gets executed it will connect to my web app server, will check allowed quota and if allowed will process 100 images(because we cannot keep waiting for request every image inference will go very slow), after 100 images it will again check for allowed quota..

Requirements..
1) keep track of usage
2) manually updatable quota and client management
3) api key management, I should be able to provide api keys to client


Is there any open source library which can help?
Will be hosting on GCP but didn't find any service on gcp

/r/django
https://redd.it/189s1yn
Fastest Screen Capturing library for Python checkout windows-capture

I was building an AI for "help" in video games and I found out that most Python screen-capturing libraries are very slow so I made one in Rust here is the repository: https://github.com/NiiightmareXD/windows-capture/tree/main/windows-capture-python

And here is the benchmark

/r/Python
https://redd.it/189xeqy
RMount allows you to create a file-system like connection to a cloud storage i.e. S3 or SSH server

RMount is a lot more robust than existing libraries and methods to create a remote connection to a cloud server. For example you would want to use Python to connect to a cloud storage such as S3 or a remote server via SSH and treat it like a local file-system.

Note

It has been a pain to write this library given how many things can go wrong when treating a cloud storage as a local file-system. For example, connection drops, or writing of large files can make the system unresponsive and lead to loss of data. The library is supposed to take care of such cases but it is always subject to unforeseen failures.

Feel free to try it out

or pip install rmount

Examples

Google Colab

/r/Python
https://redd.it/18a2sn8
Flask App Stopped Routing! Help!

So this was working not more than an hour ago and now every time I try to route to anything in my routes.py file I am getting a Not Found (404) error. However, a manual route in my __init__.py file works just fine. I've done everything I can think of to correct and undid any changes in the last hour but nothing seems to be working. Please help, I'm about to scrap all of this and just build again, which I really really don't want to do.

&#x200B;

Folder Structure

&#x200B;

run.py

from flask import Flask
from snapflask import app
if name == 'main':
app.run(debug=True)

\
_init__.py

from flask import Flask
import pyodbc
app=Flask(name)
cnxnstr = ('Driver={SQL Server};' 'Server=AllenAlienware\SQLEXPRESS;' 'Database=snap;' 'Trustedconnection=yes;')
app.config['SECRET
KEY']='key' cnxn = pyodbc.connect(cnxnstr, autocommit=True) crsr = cnxn.cursor()
u/app.route('/test') def test
route(): return 'This is a test route'

routes.py

from snapflask import app, crsr, cnxn
from snap
flask.User import User
from flask import rendertemplate, redirect, urlfor, flash
from snapflask.forms import RegisterForm, LoginForm
from flask
login import

/r/flask
https://redd.it/18a0tyd
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/18a77w3
Why use the ORM over standard SQL?

I am learning Django and have an intermediate understanding of SQL. I had previously set up scripts with a cursor in Python to just run SQL queries. I'm wondering why Django has you use the ORM to run SQL statements as opposed to just letting you write them in as is?

For example when creating columns:

name = models.CharField(max_length = 50)

instead of the simpler:name VARCHAR(50)

I am fine learning the ORM, but it seems pointless if I already know SQL. Considering that some of my scripts and views in SQL are 100+ lines long, I am anticipating that this is going to be a needless complication trying to rewrite this in the ORM.

So what is the rationale for using the ORM and why does it make you use it if it's literally just going to convert it to SQL before passing it to the SQL server?

/r/django
https://redd.it/189z57p
Python module that would operate computer like self operating computer using computer vision

So we have multiple modules like selenium etc that automate the computer / web page interaction. Now, self operating computer script that was just released tries to explain to gpt4 what it is looking at on computer screen with gpt 4 vision and allows it to use the computer according to a prompt.

It seems to me that there should be a module that does the same. Explains to llm what it can do with prompts using mouse / keyboard. Customized to different os's.

So then all we would have to do is load the module and be able to do something similar for our own special needs.

Is anyone working on something like this?

/r/Python
https://redd.it/18aaemr
Great examples of multi-language flask apps? looking for inspiration

Greetings! I'm thinking to add multi-language support to https://github.com/dgtlmoon/changedetection.io

What's the typical "best practice" workflow here? Something supporting gettext/.po files, which can be edited in another app, and use those strings in the app itself?

(My dream/idea is to have the language flag available in the app, just like any ordinary website)

Whats some flask based webapps that do this really well, that I could check out for inspiration?


Thanks for your time all!

/r/flask
https://redd.it/189y1nc
SSHaMan: A TUI for Managing SSH connections using Python & Textual

Good evening everyone. I just wrapped up my first open source project. It's functional at the moment, but definitely still alpha. It's a tool that you can use to manage SSH connections from inside the terminal.

I'm a pretty avid self-hoster with... a lot... of self-hosted services and keeping track of all my VMs is kind of painful with a .bashrc file. So I thought I'd feed two birds with one scone here and make an application to help that and also learn the Textual framework. This application presently doesn't do much that their demos don't do (I was able to repurpose their FileTree and just extend a few buttons), but I plan on digging in and learning Textual in subsequent versions to make this even more useful.

I would welcome any feedback! If anyone would like to contribute, I am absolutely open to PRs as well!

EDIT: D'oh! Forgot the link!

https://github.com/cornyhorse/sshaman

/r/Python
https://redd.it/18a9w1m
Visual Explanation of Python Panda Library

Coveres all the basic concepts of panda library like import/export create modify dataframe, add/edit/update/delete rows/coloumns, select through columns names, index, loc, iloc, iat, query and other advance methods, group by, multi-level index, and much more.

https://solothought.com/tutorial/python-pandas-visual/

\#pandas #quickreference

https://preview.redd.it/83x7u8rty74c1.jpg?width=2693&format=pjpg&auto=webp&s=4d5090f0703fded41dae3b2e41af6aab173971c6

/r/Python
https://redd.it/18adyz9
map-nl: Quickly create PC4 maps of the Netherlands

I just released a new small hobby project: map-nl

[Github](https://github.com/fpgmaas/map-nl)

It is a Python package that helps users quickly create maps of the Netherlands at the Postal Code 4 level. Nothing groundbreaking, but fun to develop and hopefully useful to some nonetheless. For example, creating a choropleth map of the Netherlands becomes as simple as:

import pandas as pd
from map_nl import ChoroplethMapNL

df = pd.read_csv("https://raw.githubusercontent.com/fpgmaas/map-nl/main/data/woz-pc4.csv")

m = ChoroplethMapNL(geojson_simplify_tolerance=0.0001).plot(
df,
pc4_column_name="pc4",
value_column_name="WOZ",
legend_name="Average WOZ Value"
)
m.save("map.html")

Curious for your thoughts, please let me know if you have any feedback!

/r/Python
https://redd.it/18afn9r
Flashcard app

Hey all. I built a flashcard app but am having issues with it loading in my browser. It works on phone so I’d like to see if it will load in your browser. Please take a peek.

www.flashcardzz.com

/r/djangolearning
https://redd.it/18a1yy4
What's new in Django 5.0 video

Made an overview of Django 5.0 key features and community updates: https://youtu.be/lPl5Q5gv9G8?feature=shared

This is my first video and I want to deliver value to the community, so please tell me what you liked and what I can do differently next time.

I feel truly honored to be part of the Django community. Hoping I will be warmly welcomed while I fumble my way through video content 💚

/r/django
https://redd.it/18aj6ep
Where do you get your images from?

I am building this flask web app and want to put in some images, but I don't know where from. To be specific: do I just put the URL of an image from online, do I download them and just use the local path or do I just do something else like make a public git-repo and use that URL. Any help is appreciated!

/r/flask
https://redd.it/18a0fo9
Why is ´print´ not recommended in linters?

I am writing a mini-program for basic payment calculation, and after the calculation the results are printed in the terminal. However, I get the following warnings from Ruff (the Python linter that I use):

src/pfexample/foodpayment.py:39:5: T201 print found
src/pfexample/foodpayment.py:51:5: T201 print found
src/pfexample/foodpayment.py:52:5: T201 print found
src/pfexample/foodpayment.py:54:5: T201 print found
src/pfexample/foodpayment.py:56:9: T201 print found

I know that I can turn off this check in the settings, BUT I don't why print is bad in the code. What would be the alternatives if not using print?

/r/Python
https://redd.it/18aiy0v
When should I start learning flask?

So basically I am a 12th grade student who have a sound knowledge of python basics, functions, file handling and exception handling. I am planning to move on to OOPs and making some projects after I finish my final examinations. But before I do that i have a doubt like what are the exact pre requisites I need to learn in python before moving to any python framework(like flask).

/r/flask
https://redd.it/18ararx
Highest Paying Django Companies

I was doing some scraping and now have a db of about 4k job openings. About 200 of those are specifically hiring for Django Developers. I created a page that list the companies that pay the most for Django Developers.

Check it out here: https://gettjalerts.com/jobs/django/highest-paid/

P.S. You can also create an alert that will notify you of any new Django jobs on the market (on the home page).

/r/django
https://redd.it/18alhqy