run cgi scripts inside asgi
Project description
✨ asgi-cgi-handler ✨
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a24b3f597489c0370ddc34088ee1919b752081cf1f0d702d9dd9a57fd9922097 |
|
MD5 | 139ca954453af3b62c2ca0819ff8dcc7 |
|
BLAKE2b-256 | aee1f82577188500cbd9aa3bdc7b3be5b1029d52545a4e2b0b3bdbc42bfd1b58 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51a65ddfbe10ce52f1cabede053e56c8a2aa63ec6a4f7a29855193d3e625b1c7 |
|
MD5 | 29b909fb6aadfeabc4a651fd5fdc2cff |
|
BLAKE2b-256 | 08da0926550ab46e87a4ed33baf74a5f2d4d9c4e19fb7fa287e4d48fa887e03d |