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


  • Python 3.6+
  • Flask 2.0+


$ 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

def index() -> Resp:
    """index page"""
    return {"code": 0, "msg": "success", "data": {}}
$ export FLASK_APP=main:app
$ flask run --reload
  * Running on (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:


This project is licensed under the terms of the MIT license.