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 details)

Uploaded Source

Built Distribution

asgi_cgi_handler-0.0.1.dev1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file asgi-cgi-handler-0.0.1.dev1.tar.gz.

File metadata

  • Download URL: asgi-cgi-handler-0.0.1.dev1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.8.2 requests/2.24.0 setuptools/60.9.3 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.8.5

File hashes

Hashes for asgi-cgi-handler-0.0.1.dev1.tar.gz
Algorithm Hash digest
SHA256 a24b3f597489c0370ddc34088ee1919b752081cf1f0d702d9dd9a57fd9922097
MD5 139ca954453af3b62c2ca0819ff8dcc7
BLAKE2b-256 aee1f82577188500cbd9aa3bdc7b3be5b1029d52545a4e2b0b3bdbc42bfd1b58

See more details on using hashes here.

File details

Details for the file asgi_cgi_handler-0.0.1.dev1-py3-none-any.whl.

File metadata

  • Download URL: asgi_cgi_handler-0.0.1.dev1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.8.2 requests/2.24.0 setuptools/60.9.3 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.8.5

File hashes

Hashes for asgi_cgi_handler-0.0.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 51a65ddfbe10ce52f1cabede053e56c8a2aa63ec6a4f7a29855193d3e625b1c7
MD5 29b909fb6aadfeabc4a651fd5fdc2cff
BLAKE2b-256 08da0926550ab46e87a4ed33baf74a5f2d4d9c4e19fb7fa287e4d48fa887e03d

See more details on using hashes here.

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