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
Built Distribution
File details
Details for the file APIFlask-0.1.0.tar.gz
.
File metadata
- Download URL: APIFlask-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1fe0d01e62d0318e5a6e24c7483491b46ca85427765c203871e50a54719a241 |
|
MD5 | 02de21ddbb98ed2a27578f958822afcf |
|
BLAKE2b-256 | 315637142588db3d153500f5a0d2a31ade8c5aa8f2fc47902555cc515c05f68d |
File details
Details for the file APIFlask-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: APIFlask-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe253d77b8a35a25685f0e826ee435a60d0117df65201416aedc0ab6b34108f8 |
|
MD5 | 4d91c9827899577b1cdca3dbe1602852 |
|
BLAKE2b-256 | c99203786496dc01f023005d52ec5dec416cc69f9333e89f3667fae7e3268842 |