-
Python 3.7 - Follow instructions to install the latest version of python for your platform in the python docs
-
Virtual Environment - We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organized. Instructions for setting up a virual environment for your platform can be found in the python docs
-
PIP Dependencies - Once your virtual environment is setup and running, install the required dependencies by navigating to the
/backend
directory and running:
pip install -r requirements.txt
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
SQLAlchemy is the Python SQL toolkit and ORM we'll use to handle the lightweight SQL database. You'll primarily work in
app.py
and can referencemodels.py
. -
Flask-CORS is the extension we'll use to handle cross-origin requests from our frontend server.
With Postgres running, create a trivia
database:
For Linux
createdb trivia
For windows
cd into backend dir
psql trivia postgres
\i trivia.psql
Populate the database using the trivia.psql
file provided. From the backend
folder in terminal run:
For Linux
psql trivia < trivia.psql
For windows
cd into backend dir
psql trivia postgres
\i trivia.psql
For no windows OS
From within the ./src
directory first ensure you are working using your created virtual environment.
To run the server, execute:
flask run --reload
The --reload
flag will detect file changes and restart the server automatically.
For windows OS
From within the ./src
directory first ensure you are working using your created virtual environment. enter the following command in order.
$env:FLASK_APP = "flaskr"
$env:FLASK_ENV: "development"
flask run
To deploy the tests, run
Linux
dropdb trivia_test
createdb trivia_test
psql trivia_test < trivia.psql
python test_flaskr.py
Windows
(form within the backend dir)
psql postgres postgres
drop database trivia_test
create database trivia_test
\c trivia_test
\i trivia.psql
python test_flaskr.py
Please check here for the API documentation and test queries
🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤🐱👤