2017-09-24 19:10:41 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import asyncio
|
|
|
|
from aiohttp import web
|
2017-03-21 11:26:25 +01:00
|
|
|
|
|
|
|
from pos.config import Config
|
2017-09-24 19:10:41 +02:00
|
|
|
from pos.logging import setup_logging, get_logger
|
|
|
|
from pos.database import Database
|
|
|
|
from pos.routes import setup_routes
|
2017-03-21 11:26:25 +01:00
|
|
|
|
|
|
|
log = get_logger('web')
|
|
|
|
|
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
def setup_app(loop, config):
|
|
|
|
app = web.Application(loop=loop)
|
2017-03-21 11:26:25 +01:00
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
app['config'] = config
|
|
|
|
app['db'] = Database(**config.core['DATABASE'])
|
2017-03-21 11:26:25 +01:00
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
setup_routes(app)
|
2017-03-21 11:26:25 +01:00
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
return app
|
2017-03-21 11:26:25 +01:00
|
|
|
|
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
config = Config()
|
|
|
|
setup_logging(config.logging)
|
2017-03-21 11:26:25 +01:00
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
loop = asyncio.get_event_loop()
|
2017-03-21 11:26:25 +01:00
|
|
|
|
2017-09-24 19:10:41 +02:00
|
|
|
app = setup_app(loop, config)
|
|
|
|
web.run_app(app,
|
|
|
|
host=config.core.get('GENERAL', 'Address'),
|
|
|
|
port=config.core.getint('GENERAL', 'Port'))
|