async def run(): conn = await asyncpg.create_pool(user='******', password='******', database='msp', host='db') logging.info('Connected to database') tm = ThrustManager() server = Webserver(conn, '0.0.0.0', '5001', tm) worker = Worker(conn, tm) server.worker = worker await asyncio.wait([ asyncio.create_task(server.run()), asyncio.create_task(worker.run()), ]) await conn.close()
import json from webserver import Webserver with open('configs/config.json') as config_file: playlist = json.load(config_file)["playlist"] if __name__ == '__main__': webserver = Webserver(playlist) webserver.run()
def main(): server = Webserver("0.0.0.0", 80, 5, os.path.dirname(os.path.abspath(__file__)) + "/static") server.add_handler(handle_comments, "POST", "/comments") server.add_handler(handle_orders, "POST", "/orders") server.run()