-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (30 loc) · 867 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from aiohttp import web
from aiohttp_utils import Response, routing, negotiation, run, path_norm
app = web.Application(router=routing.ResourceRouter())
async def index(request):
return Response('Hi There')
class HelloResource():
async def get(self, request):
name = request.GET.get('name', 'World')
return response({
'message': 'Hello' + name
})
with routing.add_route_context(app) as route:
route('GET', '/', index)
# app.router.add_resource_object('/', HelloResource())
# Content negotiation
# negotiation.setup(
# app, renderers={
# 'application/json': negotiation.render_json
# }
# )
path_norm.setup(app)
if __name__ == '__main__':
# Development server
run(
app,
# app_uri='main:app',
# reload=True,
port=8000,
host='0.0.0.0'
)