Skip to content

picsouds/flask-smorest-example-bookmanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

flask-smorest-example

Flask application example using the awesome flask-smorest: Flask/Marshmallow-based REST API framework
Widely inspired by https://github.com/lafrech/flask-smorest-sqlalchemy-example

Capture-d-cran-du-2020-08-03-20-28-16.png

Packages

  • flask-smorest
  • flask-marshmallow / Flask-SQLAlchemy and marshmallow-sqlalchemy.
  • flask-jwt-extended

Database

Sqlite with delete cascade (relation an author - many book)

Running locally

Set up Python environment:

$ pipenv install

To create a virtual environment you just execute the $ pipenv shell.

Run a development server:

$ FLASK RUN

Runs tests:

$ pipenv run python -m pytest tests/test_api.py::TestApi

Play with API

  • Open http://127.0.0.1:5000/swagger-ui in your favorit browser
  • /auth
    • Get un JWT token for the protected endpoint
  • /authors with a valid JWT token for POST / PUT / DELETE
    • PUT (need a valid etag in the If-Match HTTP request header)
    • DELETE (need a valid etag and delete cascade books)
  • /books with a valid JWT token for POST / PUT / DELETE
    • PUT (need a valid etag in the If-Match HTTP request header)
    • DELETE (need a valid etag)

Have Fun.