A Flask application can be as simple as a single file, but as a project gets bigger, it becomes overwhelming to keep all the code in one file. Python projects use packages to organize code into multiple modules.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pallets/flask/llms.txt
Use this file to discover all available pages before exploring further.
Create Project Directory
Set up virtual environment
Follow the installation instructions to set up a Python virtual environment and install Flask for your project.
Project Structure
The project directory will contain:flaskr/- A Python package containing your application code and filestests/- A directory containing test modules.venv/- A Python virtual environment where Flask and other dependencies are installed- Installation files telling Python how to install your project
- Version control config, such as git
Simple vs Structured Application
A minimal Flask application can be a single file:hello.py
Final Directory Layout
By the end of the tutorial, your project layout will look like this:Version Control
If you’re using version control, the following files should be ignored:.gitignore
You should make a habit of using version control for all your projects, no matter the size.
