Metadata-Version: 2.1
Name: asgi-cgi-handler
Version: 0.0.1.dev1
Summary: run cgi scripts inside asgi
Home-page: https://github.com/synodriver/asgi-cgi-handler
Author: synodriver
Author-email: diguohuangjiajinweijun@gmail.com
Maintainer: synodriver
License: GPLv3
Keywords: asyncio,asgi,cgi
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.8
Description-Content-Type: text/markdown

<h1 align="center"><i>✨ asgi-cgi-handler ✨ </i></h1>

[![pypi](https://img.shields.io/pypi/v/asgi-cgi-handler.svg)](https://pypi.org/project/asgi-cgi-handler/)
![python](https://img.shields.io/pypi/pyversions/asgi-cgi-handler)
![implementation](https://img.shields.io/pypi/implementation/asgi-cgi-handler)
![wheel](https://img.shields.io/pypi/wheel/asgi-cgi-handler)
![license](https://img.shields.io/github/license/synodriver/asgi-cgi-handler.svg)
![action](https://img.shields.io/github/workflow/status/synodriver/asgi-cgi-handler/build%20wheel)

- run cgi scripts inside an asgi server


- simple usage
```python
import uvicorn
from asgi_cgi import HTTPCGIHandler, WebsocketCGIHandler

uvicorn.run(HTTPCGIHandler())
```

- A more complex example
```python
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](https://github.com/joewalnes/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

```python
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: ...

```

