2017-10-02 00:47:22 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import asyncio
|
|
|
|
from aiohttp import web
|
2017-09-30 01:36:10 +02:00
|
|
|
|
2017-09-30 02:45:43 +02:00
|
|
|
from autogestionale.config import Config
|
2017-10-02 00:47:22 +02:00
|
|
|
from autogestionale.logging import setup_logging, get_logger
|
2017-09-30 02:45:43 +02:00
|
|
|
from autogestionale.database import Database
|
|
|
|
from autogestionale.routes import setup_routes
|
2017-09-30 01:36:10 +02:00
|
|
|
|
|
|
|
log = get_logger('web')
|
|
|
|
|
|
|
|
|
|
|
|
def setup_app(loop, config):
|
|
|
|
app = web.Application(loop=loop)
|
2017-10-02 00:47:22 +02:00
|
|
|
|
2017-09-30 01:36:10 +02:00
|
|
|
app['config'] = config
|
2017-10-02 00:47:22 +02:00
|
|
|
app['db'] = Database(**config.core['DATABASE'])
|
|
|
|
|
2017-09-30 01:36:10 +02:00
|
|
|
setup_routes(app)
|
|
|
|
|
|
|
|
return app
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
config = Config()
|
2017-10-02 00:47:22 +02:00
|
|
|
setup_logging(config.logging)
|
2017-09-30 01:36:10 +02:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
app = setup_app(loop, config)
|
|
|
|
web.run_app(app,
|
|
|
|
host=config.core.get('GENERAL', 'Address'),
|
|
|
|
port=config.core.getint('GENERAL', 'Port'))
|