forked from asvetlov/aiohttp-csrf
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest.py
More file actions
36 lines (22 loc) · 684 Bytes
/
test.py
File metadata and controls
36 lines (22 loc) · 684 Bytes
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
import asyncio
from aiohttp import web
async def hello(request):
return web.Response(text="Hello, world")
def dec(handler):
def wrapped(*args, **kwargs):
request = args[-1]
import ipdb;ipdb.set_trace()
return handler(*args, **kwargs)
return wrapped
class MyView(web.View):
@dec
async def get(self):
return web.Response(text="Get Hello, world")
async def post(self):
return web.Response(text="Post Hello, world")
@web.middleware
async def middleware(request, handler):
return await handler(request)
app = web.Application(middlewares=[middleware])
app.router.add_route('*', '/', MyView)
web.run_app(app)