דברים שרואים מכאן לא רואים בכלל
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728
  1. import requests
  2. import logging
  3. from flask import Flask
  4. from flask import render_template
  5. DISTANCE_URL = "http://192.168.115.23/d"
  6. def get_distance():
  7. response = requests.get(DISTANCE_URL)
  8. try:
  9. return response.json()["distance"]
  10. except Exception as e:
  11. logging.error(e)
  12. return 0
  13. app = Flask(__name__)
  14. @app.route("/")
  15. def main():
  16. return render_template("index.html")
  17. @app.route("/d")
  18. def distance():
  19. return {"distance": get_distance()}
  20. @app.route("/p")
  21. def progbar():
  22. return render_template("progbar.html")