From f947740d1e7b11348f04d463c0ab305149378494 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 26 Mar 2023 23:39:24 +0200 Subject: [PATCH] set cherrypy host and port from command line args --- stand/restapi.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/stand/restapi.py b/stand/restapi.py index 6c5084d..e110774 100644 --- a/stand/restapi.py +++ b/stand/restapi.py @@ -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()