A Web API development toolkit for Flask.
Project description
APIFlask
A lightweight Web API toolkit for Flask, based on marshmallow-code projects and other Flask extensions.
Currently this project is in plan/experimental stage, break changes are expected. Improvement and suggestions are welcome!
Installation
$ pip install apiflask
Example
from apiflask import APIFlask
from apiflask.decorators import arguments, body, response
from marshmallow import Schema
app = APIFlask(__name__)
class PetSchema(Schema):
id = Integer(dump_only=True)
name = String(required=True)
age = Integer(required=True)
category = String(required=True)
@app.route('/pets/<int:pet_id>')
@response(PetSchema)
def get_pet(pet_id):
pass
@app.route('/pets', methods=['POST'])
@body(PetSchema)
@response(PetSchema)
def create_pet(pet):
pass
@app.route('/pets', methods=['PUT'])
@body(PetSchema)
@response(PetSchema)
def update_pet(updated_pet, pet_id):
pass
Save the file as app.py
, then run it with:
$ flask run
Now visit the interactive docs by Swagger UI at http://localhost:5000/docs:
Or you can visit the alternative Redoc docs at http://localhost:5000/redoc:
The auto-generated OpenAPI spec file are available at http://localhost:5000/openapi.json.
Links
- Documentation (WIP)
- PyPI
- Change Log
APIFlask starts as a fork of APIFairy 0.6.3dev and inspired by FastAPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
APIFlask-0.1.0.tar.gz
(6.9 kB
view hashes)