88
99from aiohttpdemo_polls .middlewares import setup_middlewares
1010from aiohttpdemo_polls .routes import setup_routes
11- from aiohttpdemo_polls .utils import init_postgres , load_config
12- from aiohttpdemo_polls .views import SiteHandler
11+ from aiohttpdemo_polls .utils import load_config
12+ from aiohttpdemo_polls .db import init_postgres
1313
14-
15- PROJ_ROOT = pathlib .Path (__file__ ).parent .parent
14+ PROJ_ROOT = pathlib .Path (__file__ ).parent
1615
1716
1817async def close_pg (app ):
@@ -25,18 +24,16 @@ async def init(loop):
2524 app = web .Application (loop = loop )
2625 aiohttp_jinja2 .setup (
2726 app , loader = jinja2 .PackageLoader ('aiohttpdemo_polls' , 'templates' ))
28- # load config from yaml file
29- conf = load_config (str (PROJ_ROOT / 'config' / 'polls.yaml' ))
27+ # load config from yaml file in current dir
28+ conf = load_config (str (pathlib . Path ( '.' ) / 'config' / 'polls.yaml' ))
3029
3130 # create connection to the database
3231 db = await init_postgres (conf ['postgres' ], loop )
3332 app ['db' ] = db
3433
3534 app .on_cleanup .append (close_pg )
36-
3735 # setup views and routes
38- handler = SiteHandler (db )
39- setup_routes (app , handler , PROJ_ROOT )
36+ setup_routes (app , PROJ_ROOT )
4037 setup_middlewares (app )
4138
4239 host , port = conf ['host' ], conf ['port' ]
0 commit comments