Skip to main content

A lightweight, class-based, easy-to-use ASGI framework

Project description

gazi

A lightweight, class-based, easy-to-use ASGI framework

Docs

  • main.py
from gazi import App
from home import _ as Home
from api import API

app = App()

app.handlers([Home, API])
  • home.py
from gazi.route import method
from gazi.response import HtmlResponse, Response

# Path: /*
class _:
    def __init__(self) -> None:
        pass

    # Path: /
    @method.GET
    def __render__(self) -> Response:
        return HtmlResponse("<h1>Hello, world!</h1>")
  • api.py
from gazi.response import HtmlResponse, Response
from gazi.request import Request
from gazi.route import method

# Path: /api/*
class API:
    def __init__(self) -> None:
        pass

    # Path: /api
    @method.GET
    def __render__(self) -> Response:
        return Response("API")

    # Path: /api/hello
    @method.GET
    def hello(self, request: Request) -> Response:
        return HtmlResponse(
            f"<h1>Hello world, Username: {request.query('name')}</h1>", # data
            {"test1": "test", "asd": "a"}, # headers
        )

    # Path: /api/bye?name=test
    @method.POST
    def bye(self, request: Request) -> Response:
        return HtmlResponse(f"<h1>Bye world, Username: {request.query('name')}</h1>")

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

gazi-0.1.3.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distributions

gazi-0.1.3-py3.9.egg (10.7 kB view hashes)

Uploaded Source

gazi-0.1.3-py3-none-any.whl (5.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