Skip to content

alexandlazaris/full-stack-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python flask API

A basic full-stack app using Python, apiflask and good ol' html.

Stack

Setup venv

Note

Install python dependencies in a virtual sandbox to isolate any impacts to host system.

  1. python -m venv .
  • this will generate a ./bin, ./include, ./lib and ./pyvenv.cfg in your chosen directory (. in this case)
  1. source bin/activate to activate the virtual environment
  2. pip install -r requirements.txt to install all dependencies from ./requirements.txt

Run

  1. python src/app.py
  2. head to http://127.0.0.1:5000 for app (root / is the web app)

Tip

Change local host above to any address of your choice by editing src/app.py

API docs

  1. python src/app.py
  2. head to http://127.0.0.1:5000/docs for locally hosted OpenAPI spec (auto generated)
  3. run flask spec to generate an OpenAPI 3.0 spec, which can be used to host elsewhere

img

Warning

not all routes contain the same level of information as apiflask was being explored

Tests

  1. in 1 process, start the server python src/app.py
  2. in a 2nd process, run the tests pytest tests/tests.py --html=./report.html

tests

Future additions

  • run behind reverse proxy (https://apiflask.com/tips/)
  • add configs to run different environments (dev, prod)
  • add UI form to update books & wrap up PUT /book/{id} endpoint
  • utilise db migrations
  • introduce a Bookshelf table which contains Books (1 to many)
  • dockerize the app

References

About

Basic REST API, with docs & a FE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published