From 47b30cea327420ed6f17ccc6fd521ad89f4b4e4f Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 7 Mar 2021 09:59:14 +0100 Subject: Add Makefiles and implement Config Parser in server.py --- src/server.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/server.py (limited to 'src/server.py') diff --git a/src/server.py b/src/server.py old mode 100644 new mode 100755 index 2caddd6..37fcb51 --- a/src/server.py +++ b/src/server.py @@ -2,6 +2,7 @@ # vim: shiftwidth=4 tabstop=4 expandtab +import configparser import waitress from flask import Flask @@ -14,8 +15,22 @@ def index(): return app.send_static_file("index.html") +def load_config(): + """Load ./config.ini File and read web-template Section""" + + retval = {} + + config = configparser.ConfigParser() + config.read("config.ini") + for option in config.options("web-template"): + retval[option] = config.get("web-template", option) + + return retval # dictionary with all options from web-template section + + if __name__ == '__main__': - waitress.serve(app, listen="127.0.0.1:8080") # production server / bind to port + config = load_config() + waitress.serve(app, listen="{}:{}".format(config["address"], config["port"])) # production server / bind to port #serve(app, unix_socket='/run/web-template/unix.sock') # production server / unix domain socket #app.run() # debug server - NOT FOR PRODUCTION! -- cgit v1.2.3-70-g09d2