|
@@ -7,15 +7,22 @@ Created on Sat Apr 22 17:07:13 2022
|
|
|
import time
|
|
|
import json
|
|
|
import requests
|
|
|
+import logging
|
|
|
from flask import Flask, render_template, request, flash
|
|
|
+from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
|
|
|
|
|
-# FOLDER = "src/" # docker
|
|
|
-FOLDER = "" # local
|
|
|
-
|
|
|
+FOLDER = "src/" # docker
|
|
|
+# FOLDER = "" # local
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
-app.config["TEMPLATES_AUTO_RELOAD"] = True
|
|
|
+app.wsgi_app = ProxyFix(app.wsgi_app)
|
|
|
+
|
|
|
+# w_log = logging.getLogger("werkzeug")
|
|
|
+# w_log.disabled = True
|
|
|
+app.logger.setLevel(logging.INFO)
|
|
|
+
|
|
|
+# app.config["TEMPLATES_AUTO_RELOAD"] = True
|
|
|
with open(f"{FOLDER}secret_key", "rb") as secretKeyFile:
|
|
|
app.secret_key = secretKeyFile.read()
|
|
|
|
|
@@ -56,7 +63,10 @@ def contribute():
|
|
|
"message": request.form.get("message"),
|
|
|
"timestamp": time.time()
|
|
|
}
|
|
|
+
|
|
|
add_to_database("contribute", contribution)
|
|
|
+ logging.info(contribution)
|
|
|
+ app.logger.info(contribution)
|
|
|
|
|
|
flash("Danke für's Mitmachen!", "success")
|
|
|
return render_template("contribute.html")
|
|
@@ -76,5 +86,5 @@ def add_to_database(db_name, data_to_add):
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- app.run() # localhost
|
|
|
- # app.run(host="0.0.0.0") # in network
|
|
|
+ # app.run() # localhost
|
|
|
+ app.run(host="0.0.0.0") # in network
|