Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
Project description
Flask Sugar
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
check parameters and generate API documents automatically
Documentation: https://shangsky.github.io/flask-sugar
Source Code: https://github.com/shangsky/flask-sugar
Requirements
- Python 3.6+
- Flask 2.0+
Installation
$ pip install flask-sugar
A Simple Example
# save this as main.py
from typing import Any
from flask_sugar import Sugar
from typing_extensions import TypedDict
app = Sugar(__name__)
class Resp(TypedDict):
code: int
msg: str
data: Any
@app.get("/")
def index() -> Resp:
"""index page"""
return {"code": 0, "msg": "success", "data": {}}
$ export FLASK_APP=main:app
$ flask run --reload
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Now visit the API documentation with Swagger UI at http://localhost:5000/doc:
visit the API documentation with Redoc at http://localhost:5000/redoc:
License
This project is licensed under the terms of the MIT license.
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
flask-sugar-0.0.4.tar.gz
(11.6 kB
view hashes)
Built Distribution
Close
Hashes for flask_sugar-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 518dba1c265964770f9a9742db1c0546251780bf972aeb4cfbb8f1dd16ed1ea2 |
|
MD5 | 3c94c37b0bd15769793ec33092c833d8 |
|
BLAKE2b-256 | 496b9e495b3ff0b5b0c7a60a6fa40c6dbd22b8085b6f925f58b5a3f7c4ebbc57 |