-
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
/backenddirectory 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.pyand 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 triviaFor windows
cd into backend dir
psql trivia postgres
\i trivia.psqlPopulate the database using the trivia.psql file provided. From the backend folder in terminal run:
For Linux
psql trivia < trivia.psqlFor windows
cd into backend dir
psql trivia postgres
\i trivia.psqlFor 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 --reloadThe --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.pyWindows
(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.pyPlease check here for the API documentation and test queries
π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€π±βπ€