From c9e52fbed5d5d42e319e17945ed5ab8a59274552 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 4 Jun 2023 16:10:36 +0800 Subject: bugfix: config load does not take effect --- app.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app.py (limited to 'app.py') diff --git a/app.py b/app.py new file mode 100644 index 0000000..a9e3046 --- /dev/null +++ b/app.py @@ -0,0 +1,34 @@ +import argparse +import asyncio +import os + +import uvicorn +from uvicorn.loops.auto import auto_loop_setup + +import web + + +def setup_loop(): + if os.name == 'nt': + # use ProactorEventLoop to support async subprocess on Windows + print('Driving event loop with IOCP.') + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + auto_loop_setup() + + +if __name__ == '__main__': + p = argparse.ArgumentParser(prog='utaten2tex') + p.add_argument('-l', '--host', default='127.0.0.1') + p.add_argument('-p', '--port', default='8080') + p.add_argument('-P', '--preview-pdf', action='store_true', default=False) + args = p.parse_args() + web.preview_pdf = args.preview_pdf + setup_loop() + uvicorn.run( + 'web:app', + host=args.host, + port=int(args.port), + log_level='info', + loop='none', # use custom loop initializer + ) -- cgit v1.2.3