blob: a9e30463c80e339f601ade8fde0734f6f4edc7de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
)
|