网页
综合
更新时间 2026-11-16 06:56:58
Project Layout — Flask Documentation (3.1.x)
自动蜘蛛
flask.palletsprojects.com
正文约 1434 字
Create a project directory and enter it:
Then follow the installation instructions to set up a Python virtual environment and install Flask for your project.
The tutorial will assume you’re working from the flask-tutorial directory from now on. The file names at the top of each code block are relative to this directory.
A Flask application can be as simple as a single file.
However, 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 that can be imported where needed, and the tutorial will do this as well.
The project directory will contain:
flaskr/, a Python package containing your application code and files.
tests/, 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. You should make a habit of using some type of version control for all your projects, no matter the size.
Any other project files you might add in the future.
By the end, your project layout will look like this:
If you’re using version control, the following files that are generated while running your project should be ignored. There may be other files based on the editor you use. In general, ignore files that you didn’t write. For example, with git:
Continue to Application Setup.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。