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
- flask-smorest
- flask-marshmallow / Flask-SQLAlchemy and marshmallow-sqlalchemy.
- flask-jwt-extended
Sqlite with delete cascade (relation an author - many book)
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.