Files
colony/colony/core/roles/webview/app.py
T
2026-09-19 22:08:09 +02:00

31 lines
754 B
Python

import logging
from pathlib import Path
from flask import Flask, jsonify
STATIC_DIR = Path(__file__).parent / "static"
logging.getLogger("werkzeug").setLevel(logging.WARNING)
def create_app(get_status):
app = Flask(__name__, static_folder=str(STATIC_DIR), static_url_path="/static")
@app.get("/")
def index():
return app.send_static_file("index.html")
@app.get("/api/status")
def status():
try:
payload = get_status()
except Exception:
app.logger.exception("Could not build the status")
return jsonify(error="status unavailable"), 500
response = jsonify(payload)
response.headers["Cache-Control"] = "no-store"
return response
return app