blob: 37fcb5199e551b8dc2656bb02d8ee111a1b9111d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/python3
# vim: shiftwidth=4 tabstop=4 expandtab
import configparser
import waitress
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=["GET"])
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__':
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!
|