Skip to content

atakann/Trivia-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Trivia App

Setting up the Backend

Install Dependencies

  1. Python 3.7 - Follow instructions to install the latest version of python for your platform in the python docs

  2. 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

  3. 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

Key Pip Dependencies

  • 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.

  • Flask-CORS is the extension we'll use to handle cross-origin requests from our frontend server.

Set up the Database

With Postgres running, create a trivia database:

createdb trivia

Populate the database using the trivia.psql file provided. From the backend folder in terminal run:

psql trivia < trivia.psql

Run the Server and Frontend

From within the ./backend directory first ensure you are working using your created virtual environment.

To run the server, execute:

export FLASK_APP=flaskapp
export FLASK_ENV=development
flask run --reload

The --reload flag will detect file changes and restart the server automatically.

To run the frontend, use the instructions inside ./frontend.

npm install
npm start

This will run the frontend and you will be able to interact with the backend server.

Note that you need node version 14, you can use NVM to switch between node versions.

About

Trivia App built with Flask backend and React frontend

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published