-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
executable file
·77 lines (72 loc) · 2.02 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
import argparse
from calibre_rest import GunicornApp, __version__, create_app
from config import DevConfig, ProdConfig
if __name__ == "__main__":
parser = argparse.ArgumentParser("Start calibre-rest server")
parser.add_argument(
"-d",
"--dev",
required=False,
action="store_true",
help="Start in dev/debug mode",
)
parser.add_argument(
"-c",
"--calibre",
required=False,
type=str,
help="Path to calibre binary directory",
)
parser.add_argument(
"-l", "--library", required=False, type=str, help="Path to calibre library"
)
parser.add_argument(
"-u", "--username", required=False, type=str, help="Calibre library username"
)
parser.add_argument(
"-p", "--password", required=False, type=str, help="Calibre library password"
)
parser.add_argument(
"-g",
"--log-level",
default="INFO",
choices=DevConfig.LOG_LEVELS,
required=False,
type=str,
dest="log_level",
help="Log level",
)
parser.add_argument(
"-b", "--bind", required=False, type=str, help="Bind address HOST:PORT"
)
parser.add_argument(
"-v",
"--version",
action="version",
version=f"v{__version__}",
help="Print version",
)
args = parser.parse_args()
if args.dev:
app_config = DevConfig(
calibredb=args.calibre,
library=args.library,
bind_addr=args.bind,
username=args.username,
password=args.password,
log_level=args.log_level,
)
app = create_app(app_config)
app.run()
else:
app_config = ProdConfig(
calibredb=args.calibre,
library=args.library,
bind_addr=args.bind,
username=args.username,
password=args.password,
log_level=args.log_level,
)
g = GunicornApp(app_config)
g.run()