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.2.2.tar.gz
(9.7 kB
view details)
Built Distribution
File details
Details for the file flask_typed-0.2.2.tar.gz
.
File metadata
- Download URL: flask_typed-0.2.2.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.6 Linux/6.10.10-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7842436b9e85c86b5ef35d5e49e74a1b219f2a9ec26facd3dad3dd49d00c74d |
|
MD5 | 089f9323f848079b371e210410814f2f |
|
BLAKE2b-256 | ebd71f312af01019d0374ee839a13d12bfc37a2e42f557efa4998b7258677dd4 |
File details
Details for the file flask_typed-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: flask_typed-0.2.2-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.6 Linux/6.10.10-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfbd432cd42cb778348e2ba147a8c94fd65a0320a139df8ee8d497f3fa84e4e1 |
|
MD5 | 36b7373f776cfd64ec21d625aae751dc |
|
BLAKE2b-256 | 788c6f334d9a9079314f770c2a3141696b3d7826ec66a67c7cd6fc79e386b13d |