-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsample_app.py
More file actions
40 lines (33 loc) · 1.03 KB
/
Copy pathsample_app.py
File metadata and controls
40 lines (33 loc) · 1.03 KB
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
from aiohttp import web
from navconfig.logging import logging
from navigator_auth import AuthHandler
from navigator import Application
from navigator.responses import HTMLResponse
# Middleware to print request details
@web.middleware
async def debug_middleware(request, handler):
app = request.app
for route in app.router.routes():
logging.debug(
f"Route added: {route.resource}, method: {route.method}, Path: {route.resource.canonical}"
)
logging.debug(
f"Request received: {request.method} {request.path}"
)
match_info = request.match_info
logging.debug(f"Matched info: {match_info}")
response = await handler(request)
return response
app = Application(
middlewares=[debug_middleware]
)
auth = AuthHandler()
auth.setup(app) # configure this Auth system into App.
@app.get('/')
async def hola(request: web.Request) -> web.Response:
return HTMLResponse(body="Hola Mundo")
if __name__ == '__main__':
try:
app.run()
except KeyboardInterrupt:
pass