Files
dashboard_test/app.py
Stef 6103a34ae1 Switched from browser refresh to update webpage with API fetch
Added an ID field to the API. Added a fetch script that updates the webpage every second.
2025-08-31 14:06:55 +02:00

30 lines
630 B
Python

# import requests as r
from flask import jsonify, Flask, render_template
from poll_services import start_async_loop
from mem import services
import threading
# Flask app to serve status
app = Flask(__name__)
@app.route("/")
def homepage():
return render_template("home.html", services=services)
@app.route("/api/status")
def status():
return jsonify([s.to_dict() for s in services])
# Only run if directly running file
if __name__ == "__main__":
t = threading.Thread(target=start_async_loop, daemon=True)
t.start()
# Run flask app
app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)