This sample repo contains the recommended structure for a Python Flask project. In this sample, we use flask
to build a web application and the pytest
to run tests.
For a more in-depth tutorial, see our Flask tutorial.
The code in this repo aims to follow Python style guidelines as outlined in PEP 8.
To successfully run this example, we recommend the following VS Code extensions:
-
Open the template folder in VS Code (File > Open Folder...)
-
Create a Python virtual environment using the Python: Create Environment command found in the Command Palette (View > Command Palette). Ensure you install dependencies found in the
pyproject.toml
file -
Ensure your newly created environment is selected using the Python: Select Interpreter command found in the Command Palette
-
Run the app using the Run and Debug view or by pressing
F5
-
To test your app, ensure you have the dependencies from
dev-requirements.txt
installed in your environment -
Navigate to the Test Panel to configure your Python test or by triggering the Python: Configure Tests command from the Command Palette
-
Run tests in the Test Panel or by clicking the Play Button next to the individual tests in the
test_app.py
file