| import os |
| from flask import Flask, send_from_directory |
|
|
| |
| app = Flask(__name__, static_folder='dist') |
|
|
| @app.route('/health') |
| def health_check(): |
| """Hugging Face readiness probe endpoint.""" |
| return {"status": "healthy", "version": "15.0.0"}, 200 |
|
|
| @app.route('/', defaults={'path': ''}) |
| @app.route('/<path:path>') |
| def serve(path): |
| """ |
| Serve static files. If a file is not found (e.g., during client-side routing), |
| fallback to index.html to allow React Router to handle the view. |
| """ |
| static_path = os.path.join(app.static_folder, path) |
| |
| if path != "" and os.path.exists(static_path): |
| return send_from_directory(app.static_folder, path) |
| else: |
| index_path = os.path.join(app.static_folder, 'index.html') |
| if os.path.exists(index_path): |
| return send_from_directory(app.static_folder, 'index.html') |
| else: |
| return f"Abyssinia v15 Error: Build artifacts not found in {app.static_folder}. Check Docker build stage.", 404 |
|
|
| if __name__ == "__main__": |
| |
| app.run(host='0.0.0.0', port=7860) |