Set Up a Maintainable Flask Application in a Virtual Environment
Table of Contents
Setting up a new Flask Application
Here are the steps to set up the foundation for a maintainable Flask application.
- Create a folder for our new application called
yumroad-app - With your terminal, create a virtual environment in the
yumroad-appfolder by runningpython3 -m venv env - Activate the Virtual Environment by running
source env/bin/activatein your terminal (You should see your prompt prefixed with a(env)to know that your virtual env is activated)
caution
Your virtualenv needs to be activated in every terminal session where you plan to run the application If you open a new tab or window for example and want to run commands that depend on things installed within the virtual environment, you'll need to run the activation command again.
- Create a
requirements.txtthat lists the following starting libraries as requirements
flask
gunicorn
pytest
pytest-flask
pytest-cov
- Install those libraries by running
pip install -r requirements.txt - Create a folder called
yumroadand then a file called__init__.pywithin theyumroadfolder - Setup the basic application factory pattern in the
__init__.pyfile
This lesson preview is part of the Fullstack Flask: Build a Complete SaaS App with Flask course and can be unlocked immediately with a single-time purchase. Already have access to this course? Log in here.
This video is available to students only
Unlock This Course
Get unlimited access to Fullstack Flask: Build a Complete SaaS App with Flask with a single-time purchase.
