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 run --debug
- 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 two databases:
- A development database named
task_list_api_development
- A test database named
task_list_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 databaseSQLALCHEMY_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/task_list_api_development
SQLALCHEMY_TEST_DATABASE_URI=postgresql+psycopg2://postgres:postgres@localhost:5432/task_list_api_test
Run $ flask db init
.
After you make your first model in Wave 1, run the other commands migrate
and 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 run --debug
It is highly recommended to run the Flask servers with this command.