from aiohttp import web
from jsonrpcserver.aio import methods

@methods.add
async def ping():
    return 'pong'

async def handle(request):
    request = await request.text()
    response = await methods.dispatch(request)
    if response.is_notification:
        return web.Response()
    else:
        return web.json_response(response)

app = web.Application()
app.router.add_post('/', handle)

if __name__ == '__main__':
    web.run_app(app, port=5000)

from aiohttp import web
from jsonrpcserver.aio import methods

@methods.add
async def ping():
    return 'pong'

async def handle(request):
    request = await request.text()
    response = await methods.dispatch(request)
    if response.is_notification:
        return web.Response()
    else:
        return web.json_response(response, status=response.http_status)

app = web.Application()
app.router.add_post('/', handle)

if __name__ == '__main__':
    web.run_app(app, port=5000)

Return http status in aiohttp example
Return http status in aiohttp example

  from aiohttp import web
  from jsonrpcserver.aio import methods
  
  @methods.add
  async def ping():
      return 'pong'
  
  async def handle(request):
      request = await request.text()
      response = await methods.dispatch(request)
      if response.is_notification:
          return web.Response()
      else:
-         return web.json_response(response)
+         return web.json_response(response, status=response.http_status)
  
  app = web.Application()
  app.router.add_post('/', handle)
  
  if __name__ == '__main__':
      web.run_app(app, port=5000)
  
Return http status in aiohttp example
## Code Before:
from aiohttp import web
from jsonrpcserver.aio import methods

@methods.add
async def ping():
    return 'pong'

async def handle(request):
    request = await request.text()
    response = await methods.dispatch(request)
    if response.is_notification:
        return web.Response()
    else:
        return web.json_response(response)

app = web.Application()
app.router.add_post('/', handle)

if __name__ == '__main__':
    web.run_app(app, port=5000)

## Instruction:
Return http status in aiohttp example
## Code After:
from aiohttp import web
from jsonrpcserver.aio import methods

@methods.add
async def ping():
    return 'pong'

async def handle(request):
    request = await request.text()
    response = await methods.dispatch(request)
    if response.is_notification:
        return web.Response()
    else:
        return web.json_response(response, status=response.http_status)

app = web.Application()
app.router.add_post('/', handle)

if __name__ == '__main__':
    web.run_app(app, port=5000)
