Skip to main content

run cgi scripts inside asgi

Project description

✨ asgi-cgi-handler ✨

pypi python implementation wheel license action

  • run cgi scripts inside an asgi server

  • simple usage

import uvicorn
from asgi_cgi import HTTPCGIHandler, WebsocketCGIHandler

uvicorn.run(HTTPCGIHandler())
  • A more complex example
from fastapi import FastAPI
from asgi_cgi import HTTPCGIHandler, WebsocketCGIHandler

app = FastAPI(title="CGI Server")

app.mount("/cgi-bin", HTTPCGIHandler())  # type: ignore
app.mount("/ws", WebsocketCGIHandler())  # type: ignore

As you can see, we have websocket support, which is inspired by websocketd. Currently, more tests are needed.

The WebsocketCGIHandler route requests to endpoint executables and feed websocket data into process's stdin and send stdout to client line by line.

Apis

ErrHandler = Callable[[bytes], Union[Awaitable[None], None]]

class HTTPCGIHandler:
    def __init__(self, directory: str=..., error_handler: ErrHandler=...) -> None: ...

class WebsocketCGIHandler:
    def __init__(self, directory: str=..., error_handler: ErrHandler=...) -> None: ...

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

asgi-cgi-handler-0.0.1.dev1.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

asgi_cgi_handler-0.0.1.dev1-py3-none-any.whl (6.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