summaryrefslogtreecommitdiff
path: root/src/server.py
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-03-07 09:59:14 +0100
committerxengineering <mail2xengineering@protonmail.com>2021-03-07 09:59:14 +0100
commit47b30cea327420ed6f17ccc6fd521ad89f4b4e4f (patch)
treea354a4adc5f6d2f004890750201f958db9e6a372 /src/server.py
parentf48ce5deb19d83e6d5e87f51c59e538f4b66d79e (diff)
downloadweb-template-47b30cea327420ed6f17ccc6fd521ad89f4b4e4f.tar
web-template-47b30cea327420ed6f17ccc6fd521ad89f4b4e4f.tar.zst
web-template-47b30cea327420ed6f17ccc6fd521ad89f4b4e4f.zip
Add Makefiles and implement Config Parser in server.py
Diffstat (limited to 'src/server.py')
-rwxr-xr-x[-rw-r--r--]src/server.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/server.py b/src/server.py
index 2caddd6..37fcb51 100644..100755
--- 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!