Created
December 4, 2018 18:02
-
-
Save xiaopeng163/c54c7e66a75cb830d6c63e505fa07083 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify | |
import random | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
@app.route('/temperature') | |
def get_temp(): | |
data = { | |
'data': random.uniform(10, 15) | |
} | |
return jsonify(data) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can get a random temperature value from http://127.0.0.1:8080/temperature