fix: serve dashboard.html directly from current directory instead of static folder
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@ -5,11 +5,11 @@ Provides a simple API endpoint that aggregates weather and ABS data for the dash
|
||||
This avoids CORS issues with the ABS API.
|
||||
|
||||
Run with: python3 dashboard_api.py
|
||||
Access: http://localhost:5000/api/dashboard
|
||||
Access: http://localhost:5000/
|
||||
"""
|
||||
|
||||
import requests
|
||||
from flask import Flask, jsonify
|
||||
from flask import Flask, jsonify, Response
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -155,8 +155,12 @@ def get_dashboard_data():
|
||||
|
||||
@app.route("/")
|
||||
def serve_dashboard():
|
||||
"""Serve the dashboard HTML"""
|
||||
return app.send_static_file("dashboard.html")
|
||||
"""Serve the dashboard HTML directly from the current directory"""
|
||||
try:
|
||||
with open("dashboard.html", "r", encoding="utf-8") as f:
|
||||
return Response(f.read(), mimetype="text/html")
|
||||
except FileNotFoundError:
|
||||
return "Error: dashboard.html not found. Please run from the project directory.", 404
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -165,4 +169,6 @@ if __name__ == "__main__":
|
||||
print("Error: dashboard.html not found. Please run from the project directory.")
|
||||
exit(1)
|
||||
|
||||
print("Starting dashboard server...")
|
||||
print("Open http://localhost:5000 in your browser")
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
||||
|
||||
Reference in New Issue
Block a user