Skip to content

LeoJosephson/flask-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask api project for a Game Api

This application uses Flask and PostgreSQL, Swagger for api documentation using Flasgger and Pytest for testing.

Models

  1. Game
  2. User
  3. Review
  4. Category

Quickstart

Clone repository

git clone https://github.com/LeoJosephson/flask-project.git

Installation

Make sure you have python installed

Use the package manager pip to install the additional packages

pip install -r requirements.txt

Create Environment variables

create a file (.env) in the root of the project with the following variables:

Variable name Description Example
FLASK_APP flask application project/app.py
POSTGRES_USER Postgres username "postgres"
POSTGRES_PASSWORD Postgres password "password"
POSTGRES_PORT Postgres port "5433"
HOST host "localhost"

FLASK_APP variable must be equal to project/app.py

Create database entities

make sure you are in the project folder

flask shell to start flask shell

from extensions.database import db
from models.category import Category
from models.game import Game
from models.user import User
from models.review import Review
db.create_all()

Run application

flask run 

Run application with docker

docker compose up

Run tests

Need to be in the project folder

python -m pytest

Generate Html report for test coverage

python -m pytest --cov-report html --cov

The html coverage is located at htmlcov/index.html

Access api documentation

The default endpoint is apidocs

Example: http://127.0.0.1:5000/apidocs/

About

flask api project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published