Skip to content
Beau Barker edited this page Jul 3, 2025 · 7 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)

Clone this wiki locally