The goal for setup is to cover all of the set up needed at the beginning of this project, which includes:
- Forking and cloning
- Managing dependencies
- Setting up development and test databases
- Setting up a
.env
file - Running
$ flask db init
- Running
$ flask run
and$ FLASK_ENV=development flask run
- Fork this project repo to your own personal account
- Clone this new forked project
Create a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ # You're in activated virtual environment!
Install dependencies (we've already gathered them all into a requirements.txt
file):
(venv) $ pip install -r requirements.txt
Create a database:
- A development database named
video_store_api_development
- A test database named
video_store_api_test
Create a file named .env
.
Create two environment variables that will hold your database URLs.
SQLALCHEMY_DATABASE_URI
to hold the path to your development database- [OPTIONAL]
SQLALCHEMY_TEST_DATABASE_URI
to hold the path to your development database
Your .env
may look like this:
SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://postgres:postgres@localhost:5432/video_store_api_development
SQLALCHEMY_TEST_DATABASE_URI=postgresql+psycopg2://postgres:postgres@localhost:5432/video_store_api_test
Run $ flask db init
.
After you make your first model in Wave 1, run the other commands flask db migrate
and flask db upgrade
.
Check that your Flask server can run with $ flask run
.
We can run the Flask server specifying that we're working in the development environment. This enables hot-reloading, which is a feature that refreshes the Flask server every time there is a detected change.
$ FLASK_ENV=development flask run
It is highly recommended to run the Flask servers with this command.