-
Notifications
You must be signed in to change notification settings - Fork 40
Aiohttp
Beau Barker edited this page Jul 4, 2025
·
6 revisions
Aiohttp server.
from aiohttp import web
from jsonrpcserver import Result, Success, async_dispatch, method
@method
async def ping() -> Result:
"""JSON-RPC method"""
return Success("pong")
async def handle(request: web.Request) -> web.Response:
"""Handle aiohttp request"""
return web.Response(
text=await async_dispatch(await request.text()), content_type="application/json"
)
app = web.Application()
app.router.add_post("/", handle)
if __name__ == "__main__":
web.run_app(app, port=5000)
Reference: JSON-RPC in Aiohttp.
Contributions are appreciated – simply hit Edit or New page.