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
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_typed-0.1.0rc1.tar.gz
(8.0 kB
view hashes)
Built Distribution
Close
Hashes for flask_typed-0.1.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 714c7f2c801e2635fd77bb19f7445dc6b778f715d5e54bd159ed677221a656f8 |
|
MD5 | c686d508691e9c8b5775a1cca42ce2e8 |
|
BLAKE2b-256 | 16085e8c6de8b5f5b3e738f9bfba258f2fead97e86c1fffe8cf232ed19e450fe |