Skip to main content

No project description provided

Project description

flask-typed

A Flask extension for developing HTTP APIs using type annotations. Type annotations are used for the validation of requests and generating API documentation.

Example

from flask import Flask
from pydantic import BaseModel

from flask_typed import TypedResource, TypedAPI


class HelloResponse(BaseModel):

    message: str
    sender: str
    receiver: str


class HelloResource(TypedResource):

    def get(self, sender: str, receiver: str) -> HelloResponse:
        """
        Greets someone

        :param sender: Greeter
        :param receiver: The one being greeted
        :return: Greetings
        """
        return HelloResponse(
            message=f"Hello to {receiver} from {sender}!",
            sender=sender,
            receiver=receiver
        )


app = Flask(__name__)
api = TypedAPI(app, version="1.0", description="Greetings API")

api.add_resource(HelloResource, "/hello/<sender>")

if __name__ == "__main__":
    app.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_typed-0.2.1.tar.gz (9.8 kB view hashes)

Uploaded Source

Built Distribution

flask_typed-0.2.1-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page