Skip to content

Instantly share code, notes, and snippets.

@frodo821
Last active June 23, 2018 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frodo821/6616da56252d01b118970dc952933b7e to your computer and use it in GitHub Desktop.
Save frodo821/6616da56252d01b118970dc952933b7e to your computer and use it in GitHub Desktop.
# coding: utf-8
from flask import Flask, request, render_template
app = Flask(__name__)
temperature = float("NaN")
pressure = float("NaN")
humidity = float("NaN")
@app.route("/",methods=['POST'])
def info():
global temperature, pressure, humidity
temperature = float(request.form['temp'])
pressure = float(request.form['pres'])
humidity = float(request.form['hum'])
return render_template('index.html',
t=temperature,
h=humidity,
p=pressure)
@app.route("/", methods=["GET"])
def view():
return render_template('index.html',
t=temperature,
h=humidity,
p=pressure)
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment