I am trying to run a WSGI app as described here https://aiohttp-wsgi.readthedocs.io/en/stable/wsgi.html
The following code works:
app = web.Application()
app.router.add_route("*", "/{path_info:.*}", wsgi_handler)
But, I want to add path like /hello
, so I tried following few things, none of which worked. For example:
Approach 1:
app.router.add_route("*", "/hello", wsgi_handler)
gives me 500 Internal Server Error
in the browser and on console it says:
Error handling request
Traceback (most recent call last):
File "/media/raghav/workspace/anaconda3/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/media/raghav/workspace/anaconda3/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/media/raghav/workspace/anaconda3/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py", line 158, in handler_wrapper
return await result
File "/media/raghav/workspace/anaconda3/lib/python3.7/site-packages/aiohttp_wsgi/wsgi.py", line 261, in handle_request
environ = self._get_environ(request, body, content_length)
File "/media/raghav/workspace/anaconda3/lib/python3.7/site-packages/aiohttp_wsgi/wsgi.py", line 182, in _get_environ
path_info = request.match_info["path_info"]
KeyError: 'path_info'
Approach 2:
app.router.add_route("*", "/{path_info: hello}", wsgi_handler)
gives 404: Not Found
error in the browser and says nothing on terminal.
How should I add a route?