Flask extension for creating REST APIs and OpenAPI docs with ease, inspired from FastAPI.
Project description
FlaskEase
Flask extension for creating REST APIs and OpenAPI docs with ease, inspired from FastAPI.
Checkout example here
Documentation
Documentation is coming soon :)
Try Example
$ git clone git@github.com:zero-shubham/flask-ease.git
$ cd flask-ease
$ poetry install
$ source "$( poetry env list --full-path )/bin/activate"
$ python example/main.py
Now go to http://127.0.0.1:5000/docs to find SwaggerUI docs for your API.
Simple Usage
from flask_ease import (
FlaskEaseAPI,
ResponseModel,
Depends
)
from pydantic import BaseModel
my_api = FlaskEaseAPI()
app = my_api.app
class ExampleResp(BaseModel):
txt: str
para:str
cool_txt:str
query:int
class ExampleReqBody(BaseModel):
txt: str
def call_me_first():
return "cool"
@my_api.post(
route="/<string:some_parameter>",
response_models=[
ResponseModel(
model_schema=ExampleResp,
status_code=200,
description="success"
)
],
tags=["example_route"]
)
def get_example(
some_parameter:str,
obj_in: ExampleReqBody,
query:int=0,
cool=Depends(call_me_first)
):
# Similar to FastAPI you get everything as argument
# to endpoint method
return ExampleResp(
txt = obj_in.txt,
para=some_parameter,
cool_txt=cool,
query=query
), 200
if __name__ == '__main__':
my_api.generate()
app.run(host='0.0.0.0', port=5000, debug=True)
For a complete understanding check the example here
File-uploads are not yet supported via FlaskEase - to be added soon
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
FlaskEase-0.1.5.tar.gz
(8.7 kB
view hashes)
Built Distribution
FlaskEase-0.1.5-py3-none-any.whl
(10.6 kB
view hashes)
Close
Hashes for FlaskEase-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4acc8877e0f83dcc8f63dac30be35176bbf71957232194eea3c77d78a7783b |
|
MD5 | 52b75044323e3c1b503e9982141c6c9c |
|
BLAKE2b-256 | 7a249b543c9998dfe5954b0d36523d3000569dac6f97e740def0d716c3e05a4a |