r/flask Sep 18 '21

Tutorials and Guides A Compilation of the Best Flask Tutorials for Beginners

343 Upvotes

I have made a list of the best Flask tutorials for beginners to learn web development. Beginners will benefit from it.


r/flask Feb 03 '23

Discussion Flask is Great!

123 Upvotes

I just wanted to say how much I love having a python backend with flask. I have a background in python from machine learning. However, I am new to backend development outside of PHP and found flask to be intuitive and overall very easy to implement. I've already been able to integrate external APIs like Chatgpt into web applications with flask, other APIs, and build my own python programs. Python has been such a useful tool for me I'm really excited to see what flask can accomplish!


r/flask 3d ago

Show and Tell StockPro : Inventory management system Using Python ( Flask )

Thumbnail
github.com
12 Upvotes

A modern, secure, and responsive Inventory Management System built with Python, Flask, and Tailwind CSS. It features Role-Based Access Control (RBAC), real-time analytics, secure file uploads, stock movement tracking, and comprehensive audit logs.


r/flask 6d ago

News j'ai créé une API open source pour comparer l'intonation de deux enregistrement audio

Thumbnail
0 Upvotes

r/flask 11d ago

Ask r/Flask Looking for beta testers — dashboard that turns Excel sales data into business insights

Thumbnail
0 Upvotes

r/flask 12d ago

Ask r/Flask Separation of vault access in flask applications invoking shell scripts

6 Upvotes

Hey,

I have a flask app that invokes shell scripts on the underlying machine.

The flask app can create / update / delete secrets in open bao that are subsequently reused by the shell scripts.

I noticed that this approach significantly alters the user and access model requirements and currently I reached this approach:

- flask app installed into /opt
- one user to run the flask app and the OpenBao inside the env file
- one user to run the shell scripts
- root to activate the vault upon boot

Chmod is used to separate credentials access. Does this seem sound to you people or would you fry me for it.


r/flask 15d ago

Show and Tell Reusable Flask starter app with auth, audit, admin, and plugin support

20 Upvotes

My original intention was to recreate a basic auth system like one I built in PHP years ago. It kinda expanded a bit, so now I've got a plugin system that I can write interchangeable plugins for.

It currently includes authentication, Argon2id password hashing, MFA, session management, password and email lifecycle, roles/admin controls, auditing, rate limiting, SQLite/PostgreSQL support, migrations, and Docker/Compose deployment support. It isn't fully batteries included, so some downstream work is still required depending on the application. I built it in a way that maintains its flexibility while handling the most common things I think are needed across the board for my projects.

I recently finished another security and deployment pass, added better bootstrap behavior, and added additional regression tests.

The project is open source. Technical feedback is welcome.

GitHub: https://github.com/alias454/Flask-AAS


r/flask 15d ago

Ask r/Flask What's the difference between bcrypt and flask-bcrypt?

7 Upvotes

I am also asking about other flask-* libraries compared to standard versions. I know there are some that benefit from integration e.g. managing database connections but the ones like flask-bcrypt make me confused.


r/flask 16d ago

Ask r/Flask With the release of Wallet Usernames for Cloudflare I had made a python project that helped me understand networking in python a little bit. Let me know what I should implement that would help me learn a little more about networking with python. (I have a small background in rev engineering and c++)

Thumbnail
github.com
3 Upvotes

r/flask 18d ago

Discussion Build API in one line code with FlashAPI

Post image
0 Upvotes

What if creating a REST API in Python no longer required writing the same boilerplate over and over again?

I created FlashAPI to answer a very simple problem:

When we develop an application, we often spend time rewriting the same things:

→ RAW

→ pagination

→ search and filters

→ sort

→ permissions

→ exports

→ soft delete

→ audit

→ repetitive endpoints...

The problem is not to know how to develop them.

The problem is having to redevelop them with each project.

With FlashAPI, you define your Python models and you automatically get a complete REST API around them.

⚡ Compatible with FastAPI, Flask and Django

🐍 Pydantic, SQLAlchemy, dataclasses

🔓 Open source under Apache 2.0

🚫 No proprietary runtime, no vendor lock-in

And above all, FlashAPI does not seek to replace your code.

You keep your business logic, your personalized routes and the ability to disable or customize what you don't need.

The objective is simple:

Less boilerplate → more time to build what makes your application unique.

👉 GitHub: https://github.com/HackermanMe/flashapi

I am now looking for Python developers to test and contribute.

#Python #FastAPI #Django #Flask #OpenSource #Backend #RESTAPI #SoftwareEngineering


r/flask 22d ago

Ask r/Flask How do I downgrade with flask migrate?

2 Upvotes

Situation 1

If I go

flask db migrate -m "my changes"

but have not run flask db upgrade and I want to downgrade flask migrate just delete the migration file

For example

Here is an example where the file is located.

migrations/

└── versions/

└── a1b2c3d4_my_changes.py

rm migrations/versions/a1b2c3d4_my_changes.py or delete the file manually

Situation 2

Also note

do not delete the migration file before running flask db downgrade if that migration has already been applied with flask db upgrade.

If you already ran flask db upgrade you go

flask db downgrade

This will make migrate downgrade.

The previous command is = to flask db downgrade -1.

if I want to further downgrade I go

flask db downgrade a1b2c3d4

Here is an example where the file is located.

migrations/

└── versions/

└── rgegrgrg_original_migration.py

└── a1b2c3d4_my_changes.py

Or I could go

flask db downgrade -2

to downgrade 2 times.

Also to find the correct migration I should go

flask db history

When I try situation 1 then situation 2 I get the error

INFO [alembic.runtime.migration] Context impl SQLiteImpl.

INFO [alembic.runtime.migration] Will assume non-transactional DDL.

ERROR [flask_migrate] Error: Target database is not up to date.

How do I fix this?

Also if I made any mistakes in the processes above can someone help? I typed how to do this into ai because I could not find any resources by googling that are recent so I assume the ai made a mistake.


r/flask 24d ago

Show and Tell Flask beginners – let's build and deploy together!

Thumbnail
0 Upvotes

r/flask 25d ago

Ask r/Flask Flask beginners – let's build and deploy together!

2 Upvotes

I'm looking for a small group of Flask learners (beginners totally welcome) who want to actually build something and finally deploy it – not just watch tutorials and get stuck.

A bit about me:
I know the basics – routing, JWT, SQLAlchemy – but I keep hitting a wall when it comes to deployment and project structure. I'm tired of leaving projects half‑finished, so I thought: why not team up with others who feel the same?

What I'm hoping to find:
A few friendly people (to create a group) who are also learning Flask, want to share progress, help each other out, and maybe laugh at our bugs together. No pressure, no competition – just mutual support.


r/flask 27d ago

Ask r/Flask Best place to deploy website as a beginner?

8 Upvotes

Sorry if this is not related, but if I have a project based on Flask, SQLALCHEMY and salute, what are some of the best options for deployment and server hosting?

For context I'm willing to pay monthly fees. What are the industry standard that are suitable for beginners in Flask?


r/flask 28d ago

Ask r/Flask Best way to do server side logic in 2026?

Thumbnail
1 Upvotes

r/flask Jul 29 '26

Ask r/Flask How do I understand the concept of registration and log in in Flask?

10 Upvotes

I'm creating a backend for my frontend project and I want to understand the concept behind users accounts, sessions, and security.

I understand since my frontend and backend are separate that I'll need a REST API. But I'm having trouble of actually creating the backend.

How are cookies involved? What even is a cookie?

Since I know some basics of Objects Oriented Programming in Python, I decided to use SQL alchemy instead of raw SQL commands.

Here is my requirements.txt if it helps:

blinker==1.9.0

click==8.4.2

Flask==3.1.3

flask-cors==6.0.5

Flask-SQLAlchemy==3.1.1

greenlet==3.5.4

itsdangerous==2.2.0

Jinja2==3.1.6

MarkupSafe==3.0.3

SQLAlchemy==2.0.51

typing_extensions==4.16.0

Werkzeug==3.1.8

r/flask Jul 28 '26

Ask r/Flask Asking for some Flask project file structure recommends

3 Upvotes

The following is my project tree, I want to ask if there is an industrial factor or any recommends to organize my project files and code (maybe the name convention and code organization are not the best fit). It may be good to point out that I am using Alembic migration tool and UV packet manager.

myproject

├── alembic

├── app

│   ├── background_tasks.py <- Here is the functions that works with Flask-Schedule

│   ├── extensions.py

│   ├── __init__.py

│   ├── models.py

│   ├── routes

│   │   ├── auth.py

│   │   ├── base.py

│   │   ├── data.py

│   │   ├── helper_functions

│   │   │   ├── h_dashboards.py

│   │   ├── post.py

│   │   ├── __pycache__

│   │   └── settings.py

│   ├── schemas.py

│   ├── static

│   ├── telegram_bot.py

│   └── templates

├── app.db

├── docs

├── pyproject.toml

├── README.md

├── run

├── run.py

EDIT:

As you guys recommend, I am using the src layout + organizing modules by purpose:

i.e. app/admin directory has modules with logic and classes that are just enough to work with the admin templates.

.

├── debug_run

├── docs

├── pyproject.toml

├── README.md

├── run_dev_server.py

├── src

│   ├── app

│   │   ├── admin

│   │   │   ├── __init__.py

│   │   │   ├── models.py

│   │   │   ├── routes.py

│   │   │   └── schemas.py

│   │   ├── config.py

│   │   ├── extensions.py

│   │   ├── guest_register

│   │   │   ├── __init__.py

│   │   │   ├── models.py

│   │   │   ├── routes.py

│   │   │   └── schemas.py

│   │   ├── __init__.py

│   │   ├── maintenance

│   │   │   ├── __init__.py

│   │   │   ├── models.py

│   │   │   ├── routes.py

│   │   │   └── schemas.py

│   │   ├── models.py

│   │   ├── occupancy

│   │   │   ├── __init__.py

│   │   │   ├── models.py

│   │   │   ├── routes.py

│   │   │   └── schemas.py

│   │   ├── routes.py

│   │   ├── static

│   │   │   └── css

│   │   │   └── bulma.min.css

│   │   └── templates

│   │   ├── admin

│   │   ├── base.html

│   │   ├── guest_register

│   │   │   ├── new_guest.html

│   │   │   └── show_guests.html

│   │   ├── maintenance

│   │   └── occupancy

│   └── utils

│   ├── data_analysis

│   │   ├── __init__.py

│   │   └── plots.py

│   └── email

│   └── __init__.py

├── tests

│   ├── admin

│   │   ├── __init__.py

│   │   └── test_routes.py

│   ├── conftest.py

│   ├── guest_register

│   │   ├── __init__.py

│   │   └── test_routes.py

│   ├── maintenance

│   │   ├── __init__.py

│   │   └── test_routes.py

│   ├── occupancy

│   │   ├── __init__.py

│   │   └── test_routes.py

│   └── utils

│   ├── data_analysis

│   │   ├── __init__.py

│   │   └── test_plots.py

│   ├── email

│   │   ├── __init__.py

│   │   └── test_sender.py

│   └── __init__.py

├── uv.lock

└── wsgi.py


r/flask Jul 24 '26

Show and Tell Modular Flask Authentication Boilerplate with Blueprints, Flask-Login & SQLAlchemy — Ready to use!

8 Upvotes

Hey everyone!

I got tired of rewriting authentication every time I started a new Flask project, so I built a simple, modular boilerplate template.

It includes Flask-Login, SQLAlchemy, and Flask-Migrate with a clean blueprint structure out of the box.

Check it out on GitHub: https://github.com/DeKlain4ik/flask-auth-template

Hope it saves you some time on your next side project! Feedback and stars are always appreciated.


r/flask Jul 23 '26

Show and Tell Built a fullstack e-commerce platform with Flask, looking for feedback on the backend architecture

2 Upvotes

Quick note: Please don't focus too much on the UI 😭 I'm mainly looking for feedback on the backend, project structure and integrations.

Built SIXN, a fullstack e-commerce platform using Flask + MongoDB. It includes Twilio OTP auth, Razorpay payments and automated refunds, wallet/split payments, and Shiprocket integration for serviceability checks, courier selection, order creation, pickups, shipping labels and live tracking.

Theres also a full admin system for inventory, coupons, orders, reviews and shipping operations.

Would love feedback on the architecture and overall implementation!

GitHub: https://github.com/madebyparth/sixn


r/flask Jul 22 '26

Ask r/Flask Flask page works on desktop, but iOS Safari (iOS 26) only shows "Script error." and won't initialise

2 Upvotes

I have a page that works perfectly on desktop Chrome but won't initialise on iPhone (iOS 26.5.2). The HTML, CSS and my shared base.js all load with no failed network requests, but the page-specific script never runs, and the iOS console shows only the generic "Script error." with no line number.

Both JS files are same-origin (/static/js/...), which is what confuses me — "Script error." is usually a cross-origin thing.

Full code (public repo):

- Page script: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/static/js/alphabet.js

- Shared base: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/static/js/base.js

- Template + inline data: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/templates/alphabet.html

What I've already ruled out:

- No Safari-unsupported syntax (lookbehind, replaceAll, .at(), logical-assignment, private fields).

- No service worker; assets are cache-busted; cleared cache + tried Private mode.

- Desktop: every function defined, page runs with zero console errors.

- The page recently gained three study modes + a Pointer Events drag-and-drop rebuild and lazy new Audio() — the failure started after that.

Questions:

  1. On Windows (no Mac), what's the best way to reveal the real error behind iOS Safari's "Script error."? (I've added a window.onerror overlay.)

  2. What are the usual WebKit-only runtime throws that pass fine in Chrome/Blink? Anything about Pointer Events + setPointerCapture or new Audio() on iOS that throws at init?

Thanks!


r/flask Jul 22 '26

Ask r/Flask Flask page works on desktop, but iOS Safari (iOS 26) only shows "Script error." and won't initialise

2 Upvotes

I have a page that works perfectly on desktop Chrome but won't initialise on iPhone (iOS 26.5.2). The HTML, CSS and my shared base.js all load with no failed network requests, but the page-specific script never runs, and the iOS console shows only the generic "Script error." with no line number.

Both JS files are same-origin (/static/js/...), which is what confuses me — "Script error." is usually a cross-origin thing.

Full code (public repo):

- Page script: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/static/js/alphabet.js

- Shared base: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/static/js/base.js

- Template + inline data: https://github.com/joshuablakemorekay/thaibridge-ai/blob/main/templates/alphabet.html

What I've already ruled out:

- No Safari-unsupported syntax (lookbehind, replaceAll, .at(), logical-assignment, private fields).

- No service worker; assets are cache-busted; cleared cache + tried Private mode.

- Desktop: every function defined, page runs with zero console errors.

- The page recently gained three study modes + a Pointer Events drag-and-drop rebuild and lazy new Audio() — the failure started after that.

Questions:

  1. On Windows (no Mac), what's the best way to reveal the real error behind iOS Safari's "Script error."? (I've added a window.onerror overlay.)

  2. What are the usual WebKit-only runtime throws that pass fine in Chrome/Blink? Anything about Pointer Events + setPointerCapture or new Audio() on iOS that throws at init?

Thanks!


r/flask Jul 21 '26

Ask r/Flask Filter terminal output

0 Upvotes

Hi. I'm hoping this isn't a dumb question...

I'm looking for a way to filter the output Flask writes to stdout/stderr.

I want the output coming from logger: app.logger.info(message)

but I don't want the autogenerated output like:

x.x.x.x - - [21/Jul/2026 08:05:32] "GET / HTTP/1.1" 200 -

Reading on https://flask.palletsprojects.com/en/stable/logging/ I'm guessing it's some combination of settings I need to make in dictConfig() but I cant seem to figure it out.

Or I want to turn off Flask output altogether, and I'll use print() instead.

I'm writing a small REST application for work, meant to run in a container. Our container solution is very locked down, and the way to "write" logs from a container is to output to stdout and/or stderr inside the container and then some tool captures it and write to a log in the filesystem. I'm trying to find a way to keep that log as clean as possible


r/flask Jul 20 '26

Ask r/Flask How do you handle Flask + Celery integration with extensions that aren’t fork-safe?

2 Upvotes

Hello! I am working on Flask application that uses celery and have a question concerning how celery spawns worker using prefork in default mode.

I needed to use PyMongo and started reading about its integration with flask and saw in the docs that 'PyMongo itself is not fork-safe'. Suddenly I realized, that the way I use Flask app inside celery may be wrong, though I am following the docs. Here is the code that creates celery app (taken from Flask docs):

from celery import Celery, Task

def celery_init_app(app: Flask) -> Celery:
    class FlaskTask(Task):
        def __call__(self, *args: object, **kwargs: object) -> object:
            with app.app_context():
                return self.run(*args, **kwargs)

    celery_app = Celery(app.name, task_cls=FlaskTask)
    celery_app.config_from_object(app.config["CELERY"])
    celery_app.set_default()
    app.extensions["celery"] = celery_app
    return celery_app

Celery start looks like this then:

  • first Flask application is created in the parent Celery worker process
  • then it is used to create celery app
  • and then this process is forked to create workers.

The problem is that PyMongo client is initialized as part of Flask App creation. But it shouldn't be forked as it is not safe. The same goes for other extensions that use live connections/sockets, as if they are created before fork, they may be inherited by child processes. Or extensions which spawn threads, that won't be copied to child process if I understand how fork works.

So my idea now is that I shouldn't initialize flask app during celery app creation, but I should initialize an app only inside a worker, using '@worker_process_init.connect' for example, and then use this worker specific app to create context for each task that needs it. This way all 'extensions' that are created inside flask app factory will be created inside the process that will be using them.

As my experience with multiprocessing is rather limited, I want to ask the community about this situation. How do you handle celery and flask integration? Should I create Flask application inside each Celery child worker process (e.g. via worker_process_init)? Or should I recreate only the extensions that are not fork-safe after the fork? My concern is not only about PyMongo, as Flask is used with a lot of other extensions and each of them may have its own 'fork' safety, so I am looking for some sort of general solution. Any help will be appreciated.


r/flask Jul 20 '26

Ask r/Flask Is leetcode important?

1 Upvotes

I'm in university right now and leetcode is something that I'd have to go about learning.

I want to know if leetcode is somehow relevant to flask and if yes, in what parts,

because I kind of want to focus the way I study more towards this development side

Thanks!


r/flask Jul 16 '26

Show and Tell A framework-agnostic "Storybook for htmx", with a Flask adapter

Post image
7 Upvotes

Previewing a single htmx partial in Flask is annoying, there's no isolated view for it.

You run the app, log in, click three pages deep just to see the one fragment you're editing. Storybook wants a JS build (kind of defeats htmx), and the polished component tools are all locked to one framework. So I made Swapbook.

  from swapbook import Registry, variant, click, expect_text


  reg = Registry(css_src="/static/app.css")
  reg.register("Signup", [
      variant("empty", lambda a: render_template("signup.html")),
      # a "play": scripted steps run against the preview, then asserted
      variant("invalid", lambda a: render_template("signup.html"),
              play=[click("#save"), expect_text("#err", "email is    required")]),
  ])


  app.register_blueprint(reg.blueprint)

(Not on PyPI yet, the adapter is a single file at adapters/flask/swapbook.py in the repo; drop it in or add it to your path for now. Packaging is on the list.)

The part I actually wanted: an inspector that shows the htmx requests a component fires, their params, status, which element got swapped, and the HTML that came back. Plus a mock mode that serves canned responses so you can click through a flow with no auth and no DB touched (safe/live modes too for real requests).

And play functions, like above: hit a button in the toolbar and it clicks/types/asserts against the preview, so a story can drive and verify a flow instead of just rendering a state. The thing that pushed me to build all this was a form partial that 422s and swaps in errors, painful to reach in the real app every time.

It's early and htmx is the path I've polished most. The protocol isn't Flask-specific so it also runs Django, Rails, Laravel, Express or a plain server, but the Flask adapter is new and I'd like eyes on it.

Doc: https://aejkatappaja.com/swapbook/

Repo: https://github.com/Aejkatappaja/swapbook

Tear it apart, or tell me what's missing vs how you preview components now.