It's a WSGI framework and can be used with any WSGI application server such as Gunicorn.
pip install little-api
from little_api.api import API
app = API()
# Json Response Example
@app.route("/home")
def home(request, response):
response.json = {"name": "little-api"}
# Class Base Route Example
@app.route("/book")
class BookResource:
def get(self, req: Request, resp: Response):
resp.text = "Get Books Page"
def post(self, req: Request, resp: Response):
resp.text = "Create Books Page"
# Rendering Template Example
@app.route("/template")
def template_render(req: Request, resp: Response):
resp.body = app.template(
"index.html", context={"name": "Little-Api", "title": "Best Framework"}
)
if __name__ == "__main__":
from wsgiref.simple_server import make_server
server = make_server('localhost', 8083, app=app)
server.serve_forever()
Using Gunicorn follows the standard syntax gunicorn {OPTIONS} {WSGI_PATH}:{APP_OBJECT}
,
where WSGI_PATH
uses dot notation.
gunicorn example_app:app
see Gunicorn docs for more information.