tt
Browse files- backend/app.py +13 -2
backend/app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
import locale
|
| 4 |
-
from flask import Flask
|
| 5 |
from flask_cors import CORS
|
| 6 |
from flask_jwt_extended import JWTManager
|
| 7 |
# Import for job handling
|
|
@@ -52,7 +52,7 @@ def create_app():
|
|
| 52 |
# Setup Unicode environment first
|
| 53 |
setup_unicode_environment()
|
| 54 |
|
| 55 |
-
app = Flask(__name__)
|
| 56 |
app.config.from_object(Config)
|
| 57 |
|
| 58 |
# Disable strict slashes to prevent redirects
|
|
@@ -105,6 +105,17 @@ def create_app():
|
|
| 105 |
app.register_blueprint(posts_bp, url_prefix='/api/posts')
|
| 106 |
app.register_blueprint(schedules_bp, url_prefix='/api/schedules')
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
# Health check endpoint
|
| 109 |
@app.route('/health')
|
| 110 |
def health_check():
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
import locale
|
| 4 |
+
from flask import Flask, send_from_directory
|
| 5 |
from flask_cors import CORS
|
| 6 |
from flask_jwt_extended import JWTManager
|
| 7 |
# Import for job handling
|
|
|
|
| 52 |
# Setup Unicode environment first
|
| 53 |
setup_unicode_environment()
|
| 54 |
|
| 55 |
+
app = Flask(__name__, static_folder='../frontend/dist', static_url_path='')
|
| 56 |
app.config.from_object(Config)
|
| 57 |
|
| 58 |
# Disable strict slashes to prevent redirects
|
|
|
|
| 105 |
app.register_blueprint(posts_bp, url_prefix='/api/posts')
|
| 106 |
app.register_blueprint(schedules_bp, url_prefix='/api/schedules')
|
| 107 |
|
| 108 |
+
# Serve frontend static files
|
| 109 |
+
@app.route('/', defaults={'path': ''})
|
| 110 |
+
@app.route('/<path:path>')
|
| 111 |
+
def serve_frontend(path):
|
| 112 |
+
# If the path is a file (has a dot), try to serve it from dist
|
| 113 |
+
if path != "" and os.path.exists(os.path.join(app.static_folder, path)):
|
| 114 |
+
return send_from_directory(app.static_folder, path)
|
| 115 |
+
# Otherwise, serve index.html for SPA routing
|
| 116 |
+
else:
|
| 117 |
+
return send_from_directory(app.static_folder, 'index.html')
|
| 118 |
+
|
| 119 |
# Health check endpoint
|
| 120 |
@app.route('/health')
|
| 121 |
def health_check():
|