r/flask

▲ 1 r/flask+1 crossposts

Help me what to learn ?

So guys i want to learn flask for backend. Please suggest me from where should I start and if any playlist or project that I should make side by side. I saw yt tutorials but there they are teaching frontend. I don't want to learn it for frontend, I can use ai for that. So please help me

reddit.com
u/Maleficent-Step2883 — 22 hours ago
▲ 2 r/flask

I have a method/function the problem is sometimes I want to redirect to 1 route and sometimes I want to redirect to another different route. How do I accomplish this ?

I have a method/function the problem is sometimes I want to redirect to 1 route and sometimes I want to redirect to another different route. How do I accomplish this ? I can show the code if necessary. The only solution I can think of is inside the method/function is use a string

in an if elif statements but I am wondering if there is a better way and if this is secure?

```py

if x == 'redirect to route 1'

elif y == 'redirect to route 2'

```

reddit.com
u/0_emordnilap_a_ton — 1 day ago
▲ 12 r/flask

First time deploying a Flask app to the web.

For the past few months I've been using a flask app to serve static video to various devices on my home network(raspberry pi, tablet, etc.). I would like to deploy it publicly and want to make sure it's secure. I added a login with a werkzeug hashed password and will serve the app with waitress and nginx through a domain i got on porkbun. It's just for personal use/fun/learning. Is there anything else i should do for security purposes?

reddit.com
u/OHMYDAYUMTHEYGOINHAM — 2 days ago
▲ 6 r/flask+1 crossposts

I built a free remote job board for junior devs and visa seekers as part of my MSc research — 164 users in week one with zero marketing

Hey r/sideprojects 👋

I just launched AnywhereHired (anywherehired.com) — a free remote job aggregator built with Flask + Scrapy + SQLite as part of my MSc dissertation on automated web data extraction.

**What it does:**

- 3,000+ remote jobs aggregated daily via automated Scrapy pipelines

- 1,477 visa-sponsored roles with a dedicated filter

- Dedicated junior & entry-level feed

- AI resume matching — upload your PDF, get matched instantly

- 100% free, no sign up, no paywalls

**The stack:**

- Flask + Scrapy + SQLite

- Cron-job powered scraping pipelines

- TF-IDF resume matching (upgrading to sentence transformers next)

- Deployed on a VPS

**Week one stats (all organic, zero marketing):**

- 164 active users

- 1,800+ page views

- 4,700+ events

- Traffic from UK, USA, and more

Would love feedback from this community — especially on what features to prioritise next.

🌐 anywherehired.com

u/xezbeth13 — 3 days ago
▲ 3 r/flask

WTForms vs Pydantic for forms

I’ve been using Pydantic to validate forms and have a method to translate it to the database (different models with the same data). How does this compare to using something like flask-wtf? For context, here’s my repo (look at the recipes blueprint): https://github.com/ereaso/cookbook

u/Informal-Chance-6067 — 2 days ago
▲ 6 r/flask

Flask Part 1 Up And Running

I walk through what Flask is, why it is such a popular framework, and how to get everything set up so you can begin developing right away.

youtu.be
u/Efficient-Public-551 — 2 days ago
▲ 4 r/flask

Queryable SW Architecture Diagram for Flask Repo

My company (JigsawML) builds a scanner that reads a software repo and outputs architectural diagrams. I persuaded them to provide a version that will read the Flask repo with a single button (no signups).

If you add "/open-source-projects" to the company URL, it will take you directly to the scanner. I put this in the link section.

I've left a few screenshots so that you can get a sense of what it does.
In the next few weeks, diffs and deeper granularity will be added. Oh yes, you can ask questions about the architecture using an "Ask AI" capability.

reddit.com
u/CraterLakeGodzilla — 12 days ago
▲ 5 r/flask

I built a production-ready Python rate limiter with 6 algorithms and adaptive load-sensing.

I just open-sourced smart-ratelimiter, a production-ready Python rate limiting library. Would love feedback from the community.

What it does:

Provides rate limiting for Python APIs and services. Most libraries give you one algorithm — this gives you six, all behind a consistent API with swappable storage backends.

Algorithms:

Fixed Window, Sliding Window Log, Sliding Window Counter

Token Bucket, Leaky Bucket

Adaptive Hybrid — auto-tightens under high load, relaxes when quiet. No manual tuning.

Backends: In-memory · Redis · SQLite

Usage:

pip install smart-ratelimiter

from ratelimiter import AdaptiveRateLimiter, MemoryBackend

limiter = AdaptiveRateLimiter(MemoryBackend(), limit=100, window=60)

result = limiter.is_allowed("user:42")

Links:

GitHub: https://github.com/himanshu9209/ratelimiter

PyPI: https://pypi.org/project/smart-ratelimiter/

Zero required dependencies. MIT licensed. Contributions welcome!

u/Away-Range-5276 — 14 days ago
▲ 5 r/flask

pow shield test 2 (localhost in the front, neocities in the back)

u/WW92030 — 11 days ago
▲ 8 r/flask

How can I monitor how many requests am I processing rn and how many are waiting?

hey guys, I use gunicorn with gthread. Since flask is sync. I wanna know how many concurrent requests do I get over time, and if it every exceeds worker*threads, in my case 10*10=100. and if I need to add more threads. How can I monitor it?

I use flask with gunicorn, docker, nginx in front. Also have netadata enabled.

reddit.com
u/Consistent_Tutor_597 — 18 days ago
▲ 3 r/flask

flask db = Error: No such command 'db'

OS: Windows 11 python: 3.9.13

I have two machines (main, laptop) running Windows 11. The main machine I have recently re-formatted. On this machine I've cloned my github repo, set up the environment, installed the requirements (from requirements.txt file in repo) and set up the projects configuration files.

The application itself works fine with flask run. The database can be read from and written to.

On the main machine if I do flask db migrate -m "my new table" I get the error message flask db = Error: No such command 'db'. .

Running flask --help outputs the folllowing:


  A general utility script for Flask applications.

  Provides commands from Flask, extensions, and the application. Loads the
  application defined in the FLASK_APP environment variable, or from a
  wsgi.py file. Setting the FLASK_ENV environment variable to 'development'
  will enable debug mode.

    > set FLASK_APP=hello.py
    > set FLASK_ENV=development
    > flask run

Options:
  --version  Show the flask version
  --help     Show this message and exit.

Commands:
  add-admin          Add a admin user.
  add-groups         Add / update the default groups.
  routes             Show the routes for the app.
  run                Run a development server.
  shell              Run a shell in the app context.
  sync-odoo-lines    Update the odoo line items for all open projects.
  upcoming-projects  Email notification of status of upcoming projects.

We can see here that the command db isn't added.

The additional commands I have added are visible.


On my laptop (Windows 11, not reformatted) I can follow the same steps as above and the db command is available as expected.


A simplification of my structure is as follows:

	/application/
		/application_bp_1/
		/application_bp_2/
		/application_.../
		__init__.py
	.env
	...

__init__.py contains the application configuration

app = Flask(__name__)
db = SQLAlchemy(app)
migrate = Migrate(app, db)

So far I've

  • remade the env serveral times
  • uninstall python, cleared all cache files, reinstalled

I have tried looking for similar errors it seems to be all about initialising the db correctly which I'm sure I have done. Remember, this same project, cloned from the repo, same dependencies, same python version, works fine on the laptop.

Anybody have any idea what I've missed?

Any pointers on how to debug this?

reddit.com
u/evereux — 21 days ago
▲ 8 r/flask

Flask app not finding .env variables

I've built a flask webapp, which has forms that collect data (strings) and stores it to a sqlite db. It runs on a Raspberry Pi, via Gunicorn.

For context: I have bought a .dev domain, have an active Cloudflare tunnel, deployment happens via a self-hosted GitHub runner (on Pi) and a GitHub Actions workflow.

The app is "protected" (very basic) via session cookies.

I get RunTime errors about missing environment variables.

raise RuntimeError("Missing required environment variables")

RuntimeError: Missing required environment variables

However, the .env file contains the correct values:

SECRET_KEY="15...REDACTED...78"
PASSWORD_HASH="pb...REDACTED...3b48db8"
SQLALCHEMY_DATABASE_URI=sqlite:///REDACTED.db

Not sure how to proceed... I've tried deleting the " " in the .env file, replacing them by ' '.

The project structure:

my-app/ contains:

  • LICENSE
  • README
  • run.py
  • requirements.txt
  • deploy.yml
  • my-app.code-workspace
  • REDACTED.db
  • app/
  • instance/
  • deployment/
  • __pychache__/
  • venv/

A general schema:

https://preview.redd.it/5qbulpw2urrg1.png?width=1850&format=png&auto=webp&s=341c79c475fa9214f1d89cd24c188263a5441171

reddit.com
u/Palettekop9000 — 24 days ago
▲ 15 r/flask

Is Flask good for a small real project?

Hey everyone,

I'm working on a small website for a friend and thinking of using Flask since I'm already familiar with it.

The project is actually based on my CS50 final project, which was originally an e-commerce idea, and my friend wants something pretty similar, so I’ll tweak it to fit his needs.

I just have a couple of questions:

  • Is Flask still a good choice for something like this, or should I consider something else?
  • What’s the best way to host it?
  • Also, is it okay to use the CS50 SQL library for handling the database, or should I switch to something more standard?

The site isn’t anything huge, just a simple app with some database interaction and basic features.

I might rebuild it later using something more modern, but for now I just need something that works.

Appreciate any advice 🙏

reddit.com
u/Bsam_Al_Araby — 25 days ago
▲ 15 r/flask

I've created an app for F1 fans with flask

Hello Flask enthusiasts!

After years of filling my Git repository with projects without ever deploying them to production, I’ve finally taken the plunge… I’ve developed a dashboard bringing together F1 news and statistics.

My stack:

- Flask

- Postgres / Peewee as ORM

- Celery / Redis for API / RSS data retrieval tasks

- Tailwindcss/Basecoat for the front end

I haven’t used AI; just a bit for generating models and handling repetitive tasks!

If you’d like to see the result: f1radar.com

reddit.com
u/Auran0s_ — 23 days ago
▲ 7 r/flask

How to make flask able to handle large number of io requests?

Hey guys, what might be the best way to make flask handle large number of requests which simple wait and do nothing useful. Example say fetching data from an external api or proxying. Rn I am using gunicorn. With 10 workers and 5 threads. So that's about 50 requests at a time. But say I got 50 reqs and they are all waiting on something, the new reqs would wait in queue.

What's the solution here to make it more like nodejs (or fastapi) which from what I hear can handle 1000s of such requests in a single worker. I have an existing codebase and I am unsure I wanna migrate it to fastapi. I also have a nextjs frontend. And I could delegate such tasks to nextjs but seems like splitting logic between 2 backends is kinda bad. Plus I like python and would wanna keep most of the stuff in python.

I have plenty of ram and could just increase to more threads say 50 per worker. From what I read the options available are gevent and WsgiToAsgi but unsure how plug and play they are. And if they have any mess associated with them since they are plugins forcing flask to act like async.

For now I think adding more threads will suffice. But historically had some issues. Let me know if you have any experience or any solution on what might be best way possible.

reddit.com
u/Consistent_Tutor_597 — 25 days ago
▲ 1 r/flask

Built a distributed AI platform with Flask as the backend — task parallelism across multiple machines running local LLMs

I wanted to share a project where Flask is the backbone of a distributed AI computing platform.

The architecture: a Flask API server coordinates work between multiple machines, each running their own local AI model. One machine (the "Queen") receives a complex job through the API, uses its local LLM to decompose it into independent subtasks, and distributes them to worker machines. Each worker processes its subtask independently and submits results back through the Flask API. The Queen combines everything into the final answer.

The Flask backend handles user authentication (Flask-Login), CSRF protection (Flask-WTF), role-based access control, a credit/payment system (PayPal REST API integrated), job queuing and status tracking, and a full REST API that the desktop client communicates with. SQLite via SQLAlchemy for the database.

The desktop client is a separate repo — PyQt6 GUI + CLI mode, supports 5 AI backends (Ollama, LM Studio, llama.cpp server, llama.cpp Python, vLLM). Workers poll the Flask API for available subtasks, process them locally, and submit results back.

Tested across two Linux machines (RTX 4070 Ti + RTX 5090): 64 seconds on LAN, 29 seconds via Cloudflare over the internet. Built in 7 days, one developer, fully open source, MIT licensed.

I'll share the GitHub link in the comments.

reddit.com
u/NirStrulovitz — 24 days ago
▲ 4 r/flask

CPU intensive flask app can only support 1 user per VM?

I continue to battle a lot of server config with a flask app. Just reaching out once again in case anyone has any ideas.

The current status:

Primary endpoint is a CPU intensive endpoint, taking 6 seconds to complete. Gunicorn uses Gthread worker type, 1 worker, 1 thread. This appeared to be the most performant and stable setup.

I host the flask app on one of the main cloud providers, it spins up extra replicas of the app as needed.

Essentially with some of the nuances of python, the GIL in particular, I don't seem to be able to support more than 1 concurrent user on a single machine. Either the response time doubles, or there is queuing behind the scenes. Threads competing for resources etc.

Is there anything I'm missing besides this just being a hard computation problem and the machine gets exhausted?

I know the gunicorn docs say 1 worker can support thousands of users, but does that only apply if the task is lightweight?

Thanks for any ideas... Feel like I've exhausted all gunicorn worker types, worker numbers, thread counts etc etc.

reddit.com
u/Cwlrs — 29 days ago
▲ 3 r/flask

Django / Flask devs: a couple of people started working on a security-related project

Hey,

Recently a few people started working on a security-related project for Python web apps (things like rate limiting, IP filtering, etc.), with integrations for Django and Flask.

It’s still early, but there’s already some collaboration going on.

If you’re familiar with Django / Flask and interested in this kind of backend work, feel free to take a look:

https://www.codekhub.it/

reddit.com
u/Heavy_Association633 — 24 days ago
▲ 1 r/flask

Built something to auto-fix pytest failures — does this actually solve a real problem?

Hey everyone,

Been learning Python seriously for a while

and kept running into the same frustration —

pytest fails, spend 30 minutes figuring out

why, fix it, run again, something else breaks.

So I tried building something to automate

that loop. Spent the last month on it.

It basically:

- Runs pytest on your project

- Tries to fix what's failing

- Reruns to check if fix worked

- Rolls back if it made things worse

Current honest capability:

→ Works well on import errors

→ Handles dependency conflicts

→ Simple logic bugs sometimes

→ Fails on complex multi-file issues

→ Struggles with fixture problems

My question to this community:

Is this actually a problem worth solving?

Do you spend significant time debugging

pytest failures?

And if anyone has a Python project with

failing tests they'd be willing to share —

I'd love to run it through and see what

happens. Would help me understand if this

is useful or not.

Just trying to figure out if I've built something useful or wasted a month

reddit.com
u/dager003 — 23 days ago
▲ 3 r/flask

FlaskForge | Flask Cookie Decoder/Encoder/Cracker TOOL

Built a tool for pen-testers and CTF players working with Flask apps.

live demo

Features:
- Decode any Flask session cookie instantly
- Re-encode with modified payload
- Crack the secret key using your own wordlist
- 100% client-side, no data sent anywhere

Useful for bug bounty, CTF challenges, or auditing your own Flask apps.
Please leave a star if you find it useful!

FlaskForge | razvanttn

reddit.com
u/Bulky_Patient_7033 — 22 days ago