Skip to content

j-dunham/little-api

Repository files navigation

Little-API: The little web framework that could

PyPI CI Test Example Server

It's a WSGI framework and can be used with any WSGI application server such as Gunicorn.

Installation

pip install little-api

Usage

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"}
    )

Debugging with builtin simple_server

if __name__ == "__main__":
    from wsgiref.simple_server import make_server
    server = make_server('localhost', 8083, app=app)
    server.serve_forever()

Running with Gunicorn

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.

About

The little API that could

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages