macao-pos/web.py
crudo 6b159b6eda Switch from Flask to aiohttp.
This repository now provides the REST API only.

Implemented:
 * Authorization

Need improvement:
 * Product listing

Missing:
 * Selling
2017-09-25 19:38:45 +02:00

34 lines
723 B
Python
Executable File

#!/usr/bin/env python3
import asyncio
from aiohttp import web
from pos.config import Config
from pos.logging import setup_logging, get_logger
from pos.database import Database
from pos.routes import setup_routes
log = get_logger('web')
def setup_app(loop, config):
app = web.Application(loop=loop)
app['config'] = config
app['db'] = Database(**config.core['DATABASE'])
setup_routes(app)
return app
if __name__ == '__main__':
config = Config()
setup_logging(config.logging)
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'))