asgi cgi handler
1.0.0
jalankan skrip cgi di dalam server asgi
penggunaan sederhana
import uvicorn
from asgi_cgi import HTTPCGIHandler , WebsocketCGIHandler
uvicorn . run ( HTTPCGIHandler ())
from fastapi import FastAPI
from asgi_cgi import HTTPCGIHandler , WebsocketCGIHandler , SSECGIHandler
app = FastAPI ( title = "CGI Server" )
app . mount ( "/cgi-bin" , HTTPCGIHandler ()) # type: ignore
app . mount ( "/ws" , WebsocketCGIHandler ()) # type: ignore
app . mount ( "/sse" , SSECGIHandler ()) # type: ignore
Seperti yang Anda lihat, kami memiliki dukungan websocket, yang terinspirasi oleh websocketd. Saat ini, diperlukan lebih banyak tes.
Rute WebsocketCGIHandler
meminta ke executable titik akhir dan memasukkan data websocket ke dalam stdin proses dan mengirim stdout ke klien baris demi baris.
SSECGIHandler
, artinya server send event
, sama seperti soket web, tetapi hanya mengirim stdout ke klien.
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 : ...
class SSECGIHandler :
def __init__ ( self , directory : str = ..., error_handler : ErrHandler = ...) -> None : ...