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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file flask_typed-0.2.1.tar.gz.

File metadata

  • Download URL: flask_typed-0.2.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.8.1-arch1-1

File hashes

Hashes for flask_typed-0.2.1.tar.gz
Algorithm Hash digest
SHA256 255a53cc7caf44ea7afc0910204337a1620dea1f6792a65bba33fd8fed4bb9c6
MD5 146e38232983fdf8146cd638bd515785
BLAKE2b-256 24529ae754d86d57b5f3b2bfe2e391da1c21f5c97374fd494c9fb4e1cf9122f9

See more details on using hashes here.

File details

Details for the file flask_typed-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: flask_typed-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.8.1-arch1-1

File hashes

Hashes for flask_typed-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa889fcd24c8b99f70dc1869761e376684d615545db9ff7fa1a7812e6a170617
MD5 584dacd98f0455f2e3044a2eb3604a61
BLAKE2b-256 103c8a52d3528e6aef6c90b58ef853b0814ff7c960d94641ddcc487485d12e7a

See more details on using hashes here.

Supported by

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