diff --git a/20_flask_html/app.py b/20_flask_html/app.py new file mode 100644 index 0000000..815821b --- /dev/null +++ b/20_flask_html/app.py @@ -0,0 +1,35 @@ +from flask import Flask, render_template +import random +app = Flask(__name__) + +@app.route("/") +def index(): + #Simulace ESP32 + teplota = round(random.uniform(-5,35),1) + vlhkost = random.randint(20,95) + mesto = "Praha" + + if teplota > 25: + stav = "Je teplo, běžte k vodě ☺" + elif teplota < 5: + stav = "Je zima, opatrně venku" + else: + stav = "Počasi asi OK ☻" + + return render_template("index.html", + stav = stav, + teplota=teplota, #teplota=32 + vlhkost=vlhkost, #vlhkost=58 + mesto=mesto) #mesto="Praha" + +@app.route("/o_nas") +def o_nas(): + return render_template("o_nas.html") + +@app.route("/kontakt") +def kontakt(): + return render_template("kontakt.html") + +if __name__ == "__main__": + print("Spouštím server na http://localhost:5000 ...") + app.run(host="0.0.0.0",port=5000,debug=True) \ No newline at end of file diff --git a/20_flask_html/templates/index.html b/20_flask_html/templates/index.html new file mode 100644 index 0000000..735b5d9 --- /dev/null +++ b/20_flask_html/templates/index.html @@ -0,0 +1,35 @@ + + +
+ + +Teplota: {{teplota}}°C
+Vlhkost: {{vlhkost}}%
+Máte nějaké dotazy, napište nám:
+Jsme a existujeme ☺☻☺☻☺
+Další paragraf ♥
+ + \ No newline at end of file