-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcitron-server
More file actions
executable file
·60 lines (50 loc) · 1.31 KB
/
citron-server
File metadata and controls
executable file
·60 lines (50 loc) · 1.31 KB
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
#!/usr/bin/env python3
# Copyright 2021 BBC
# Authors: Chris Newell <chris.newell@bbc.co.uk>
#
# License: Apache-2.0
"""
This script starts a web server which supports the Citron
REST API and demonstration.
"""
import argparse
import logging
from citron.citron import Citron
from citron.citron import CitronWeb
from citron.logger import logger
def main():
parser = argparse.ArgumentParser(
description="Run the Citron REST API",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("-v",
action = "store_true",
default = False,
help = "Verbose mode"
)
parser.add_argument("--model-path",
metavar = "model_path",
type = str,
required=True,
help = "Path to Citron model directory"
)
parser.add_argument("--logfile",
metavar = "logfile",
type = str,
default = None,
help = "Logfile for output"
)
parser.add_argument("--port",
metavar = "port",
type = int,
default = 8080,
help = "Port for the Citron API"
)
args = parser.parse_args()
if args.v:
logger.setLevel(logging.DEBUG)
citron = Citron(args.model_path)
web = CitronWeb(citron)
web.start(args.port, args.logfile)
if __name__ == "__main__":
main()