forked from msys2/msys2-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·34 lines (25 loc) · 914 Bytes
/
run.py
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
# Copyright 2016-2020 Christoph Reiter
# SPDX-License-Identifier: MIT
import os
import sys
import argparse
from typing import List, Optional, Union
import uvicorn
from app import app
from app import appconfig
def main(argv: List[str]) -> Optional[Union[int, str]]:
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--cache", action="store_true",
help="use local repo cache")
parser.add_argument("-p", "--port", type=int, default=8160,
help="port number")
args = parser.parse_args()
if args.cache:
base = os.path.dirname(os.path.realpath(__file__))
cache_dir = os.path.join(base, ".app.cache")
print(f"Using cache: {repr(cache_dir)}")
appconfig.CACHE_DIR = cache_dir
uvicorn.run(app, host="127.0.0.1", port=args.port)
return None
if __name__ == "__main__":
sys.exit(main(sys.argv))