-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (27 loc) · 911 Bytes
/
app.py
File metadata and controls
34 lines (27 loc) · 911 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
# -*- coding: utf-8 -*-
'''Application start module. Point of entry.
Initializing an application
Setting up a session
Setting up templates, adding routes
'''
import aiohttp_jinja2
import jinja2
from aiohttp_session import session_middleware
from aiohttp import web
from middleware import auth_middleware, pg_engine_ctx
from model import get_sekret_key
from routes import setup_routes
# initialize the application
app = web.Application(middlewares=[
session_middleware(get_sekret_key()),
# db_middleware, # migrate to app.cleanup_ctx
auth_middleware,
])
# app.on_startup.append(create_pg_engine)
# app.on_cleanup.append(dispose_pg_engine)
app.cleanup_ctx.append(pg_engine_ctx)
# specify a folder with html-templates for the template engine
aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('templates'))
# set routes
setup_routes(app)
web.run_app(app)