Initial commit: self-hosted personal radio station
Flask + React web UI with audio player, podcast queue, feed management, episode browser, music library, schedule viewer, and log tail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
"""Flask application for the Local Radio web dashboard."""
|
||||
|
||||
import os
|
||||
|
||||
from flask import Flask, send_from_directory
|
||||
|
||||
from .config import STATIC_DIR
|
||||
from .db import close_db
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__, static_folder=str(STATIC_DIR), static_url_path="")
|
||||
|
||||
# Register teardown
|
||||
app.teardown_appcontext(close_db)
|
||||
|
||||
# Register API blueprints
|
||||
from .api import status_bp, queue_bp, episodes_bp, feeds_bp, schedule_bp, music_bp, logs_bp, stream_bp
|
||||
app.register_blueprint(status_bp, url_prefix="/api")
|
||||
app.register_blueprint(queue_bp, url_prefix="/api")
|
||||
app.register_blueprint(episodes_bp, url_prefix="/api")
|
||||
app.register_blueprint(feeds_bp, url_prefix="/api")
|
||||
app.register_blueprint(schedule_bp, url_prefix="/api")
|
||||
app.register_blueprint(music_bp, url_prefix="/api")
|
||||
app.register_blueprint(logs_bp, url_prefix="/api")
|
||||
app.register_blueprint(stream_bp, url_prefix="/api")
|
||||
|
||||
# SPA catch-all: serve index.html for any non-API route
|
||||
@app.route("/", defaults={"path": ""})
|
||||
@app.route("/<path:path>")
|
||||
def serve_spa(path):
|
||||
static = app.static_folder
|
||||
if static and path and os.path.exists(os.path.join(static, path)):
|
||||
return send_from_directory(static, path)
|
||||
if static and os.path.exists(os.path.join(static, "index.html")):
|
||||
return send_from_directory(static, "index.html")
|
||||
return "<h1>Local Radio</h1><p>Frontend not built. Run: cd web/frontend && npm run build</p>", 200
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
Reference in New Issue
Block a user