Member-only story

Flask Todo: Blueprints (Part 3)

Tomas Svojanovsky
5 min readSep 3, 2023

--

Flask Blueprints lets you separate specific functionality into modules.

A Blueprint is useful when creating logically distinct features like authentication, authorization, and other parts of a web application.

Changing the structure

As our application continues to grow, we need take take some steps to ensure scalability in the future.

  • We will move our Flask config to a .flaskenv file. This approach eliminates the need to manually input configuration data via the command line, it will reduce the risk of oversight.
  • We will use the app context manager because without it, we will encounter a runtime error later. Let’s implement it now, since we are making some bigger changes.

Create .flaskenv

You can change your settings if necessary. A common issue might be that you have already registered some other application on the port we’re using here. You can try, for example, using port 3000.

FLASK_APP=app.py
FLASK_ENV=development
FLASK_RUN_PORT=8000

Create src folder

Create a folder with the name src and move all the contents there, excluding the following: .env, .flaskenv, app.py, venv and requirements.txt.

--

--

Tomas Svojanovsky
Tomas Svojanovsky

Written by Tomas Svojanovsky

I'm a full-stack developer. Programming isn't just my job but also my hobby. I like developing seamless user experiences and working on server-side complexities

No responses yet