Skip to main content

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


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)

Uploaded Source

Built Distribution

FlaskEase-0.1.5-py3-none-any.whl (10.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