12345678910111213141516171819202122232425262728 |
- import requests
- import logging
- from flask import Flask
- from flask import render_template
-
- DISTANCE_URL = "http://192.168.115.23/d"
-
- def get_distance():
- response = requests.get(DISTANCE_URL)
- try:
- return response.json()["distance"]
- except Exception as e:
- logging.error(e)
- return 0
-
- app = Flask(__name__)
-
- @app.route("/")
- def main():
- return render_template("index.html")
-
- @app.route("/d")
- def distance():
- return {"distance": get_distance()}
-
- @app.route("/p")
- def progbar():
- return render_template("progbar.html")
|