set cherrypy host and port from command line args
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import argparse
|
||||
from threading import Thread
|
||||
|
||||
import cherrypy as cp
|
||||
@ -5,9 +6,23 @@ import cherrypy as cp
|
||||
from tblctrl import TableController
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument("--host", default="127.0.0.1")
|
||||
parser.add_argument("--port", default=9090, type=int)
|
||||
|
||||
clargs = parser.parse_args()
|
||||
|
||||
|
||||
cp.config.update({
|
||||
"server.socket_host": clargs.host,
|
||||
"server.socket_port": clargs.port,
|
||||
})
|
||||
|
||||
|
||||
# creating instances here allows to use restapi etc. as singletons
|
||||
|
||||
print(">>> start restapi")
|
||||
print(f">>> start restapi on {clargs.host}:{clargs.port}")
|
||||
|
||||
restapi = TableController()
|
||||
|
||||
|
Reference in New Issue
Block a user