Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 2.07 KB

File metadata and controls

76 lines (48 loc) · 2.07 KB

Setup

Goal

The goal for setup is to cover all of the set up needed at the beginning of this project, which includes:

  1. Forking and cloning
  2. Managing dependencies
  3. Setting up development and test databases
  4. Setting up a .env file
  5. Running $ flask db init
  6. Running $ flask run and $ FLASK_ENV=development flask run

Requirements

Fork and Clone

  1. Fork this project repo to your own personal account
  2. Clone this new forked project

Managing Dependencies

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

Setting Up Development and Test Databases

Create a database:

  1. A development database named video_store_api_development
  2. A test database named video_store_api_test

Creating a .env File

Create a file named .env.

Create two environment variables that will hold your database URLs.

  1. SQLALCHEMY_DATABASE_URI to hold the path to your development database
  2. [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

Run $ flask db init.

After you make your first model in Wave 1, run the other commands flask db migrate and flask db upgrade.

Run $ flask run or $ FLASK_ENV=development flask run

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.