Refactor HTML and JavaScript structure; add health-check endpoint
- Removed inline CSS from index.html and linked to external stylesheet. - Moved JavaScript code to a separate app.js file for better organization. - Added a health-check endpoint to the Flask application for monitoring purposes. - Implemented a static file serving route to handle requests for static assets.
This commit is contained in:
1 parent
6a0929ac2e
commit
cca5dd00ae
6 files changed
+953
-1727
No files matched your search
+19
-1
@@ -14,7 +14,7 @@ import re
|
||||
import time
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from flask import Flask, render_template, send_from_directory, abort
|
||||
from flask import Flask, render_template, send_from_directory, abort, jsonify
|
||||
|
||||
# Load variables from a .env file if present (does not override real env vars)
|
||||
load_dotenv()
|
||||
@@ -171,6 +171,24 @@ def refresh():
|
||||
return 'Cache refreshed', 200
|
||||
|
||||
|
||||
@app.route('/health')
|
||||
def health():
|
||||
"""
|
||||
Health-check endpoint for load balancers / monitoring.
|
||||
Returns 200 with a JSON status when the app is running.
|
||||
"""
|
||||
return jsonify({'status': 'ok'})
|
||||
|
||||
|
||||
@app.route('/static/<path:filename>')
|
||||
def serve_static(filename):
|
||||
"""
|
||||
Serves static assets (CSS, JS, images) from the static/ directory.
|
||||
"""
|
||||
static_dir = app.static_folder or os.path.join(app.root_path, 'static')
|
||||
return send_from_directory(static_dir, filename)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Local dev server. For production, run behind a WSGI server instead, e.g.:
|
||||
# gunicorn -w 4 -b 0.0.0.0:5000 'videoplayer:app'
|
||||
|
||||
Reference in new issue
Block a user