-
Notifications
You must be signed in to change notification settings - Fork 40
Fast API
Beau Barker edited this page Jul 4, 2025
·
1 revision
FastAPI server.
import uvicorn
from fastapi import FastAPI, Request, Response
from jsonrpcserver import Result, Success, dispatch, method
app = FastAPI()
@method
def ping() -> Result:
"""JSON-RPC method"""
return Success("pong")
@app.post("/")
async def index(request: Request) -> Response:
"""Handle FastAPI request"""
return Response(dispatch(await request.body()))
if __name__ == "__main__":
uvicorn.run(app, port=5000)
Reference: JSON-RPC in Fast API.
Contributions are appreciated – simply hit Edit or New page.