summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile8
-rw-r--r--src/config.ini20
-rwxr-xr-x[-rw-r--r--]src/server.py17
3 files changed, 43 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..43ea379
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,8 @@
+# vim: shiftwidth=4 tabstop=4 noexpandtab
+
+all:
+ echo "make all - nothing to do in this pure python project ;)"
+
+debug:
+ ./server.py
+
diff --git a/src/config.ini b/src/config.ini
index 2a67194..c91e9ce 100644
--- a/src/config.ini
+++ b/src/config.ini
@@ -1,5 +1,23 @@
+; This section is for the configuration of xengineerings web-template.
+; You can use additional sections for other purposes.
[web-template]
+
+; Choose a project_name containing only characters and underscores.
+; This project_name is used for the systemd service of your
+; application (/etc/systemd/system/<project_name>.service) and the
+; folder in /opt where your application is deployed
+; (/opt/<project_name>/).
project_name=my_web_server
-friendly_project_name=My first web Server
+
+; Choose a project_description to be used for the systemd unit.
+project_description=A template for Web Applications
+
+; Select a linux user and group for execution
+user=http
+group=http
+
+; Select an IP address and port to bind to.
+address=127.0.0.1
+port=8080
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!