"feat: Update project structure documentation and add health route"
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from flask import Flask, request, jsonify, g, redirect, url_for, session as flask_session, render_template, flash, send_from_directory
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from flask_cors import CORS
|
||||
import secrets # Für bessere Salt-Generierung
|
||||
from functools import wraps
|
||||
import jwt
|
||||
@ -40,6 +41,14 @@ def create_app(config_name=None):
|
||||
"""
|
||||
app = Flask(__name__)
|
||||
|
||||
# CORS-Konfiguration für Frontend-Server
|
||||
cors_origins = os.environ.get('CORS_ORIGINS', 'http://localhost:3000').split(',')
|
||||
CORS(app,
|
||||
origins=cors_origins,
|
||||
supports_credentials=True,
|
||||
allow_headers=['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||
methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'])
|
||||
|
||||
# Bestimme Konfiguration
|
||||
if config_name is None:
|
||||
config_name = os.environ.get('FLASK_ENV', 'development')
|
||||
@ -86,6 +95,14 @@ def create_app(config_name=None):
|
||||
# Initialisierung - wird später durch create_app ersetzt
|
||||
app = Flask(__name__)
|
||||
|
||||
# CORS-Konfiguration für Frontend-Server (Legacy)
|
||||
cors_origins = os.environ.get('CORS_ORIGINS', 'http://localhost:3000').split(',')
|
||||
CORS(app,
|
||||
origins=cors_origins,
|
||||
supports_credentials=True,
|
||||
allow_headers=['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||
methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'])
|
||||
|
||||
# Initialisiere Netzwerkkonfiguration
|
||||
network_config = NetworkConfig(app)
|
||||
|
||||
@ -1705,7 +1722,30 @@ def job_status(job_id):
|
||||
|
||||
@app.route('/api/test', methods=['GET'])
|
||||
def test():
|
||||
return jsonify({'message': 'MYP Backend API funktioniert!'})
|
||||
return jsonify({'message': 'API funktioniert!', 'status': 'success'})
|
||||
|
||||
@app.route('/health', methods=['GET'])
|
||||
def health_check():
|
||||
"""Health Check Endpoint für Backend-Server"""
|
||||
try:
|
||||
# Prüfe Datenbankverbindung
|
||||
db = get_db()
|
||||
db.execute('SELECT 1').fetchone()
|
||||
|
||||
return jsonify({
|
||||
'status': 'healthy',
|
||||
'service': 'myp-backend',
|
||||
'timestamp': datetime.datetime.utcnow().isoformat() + 'Z',
|
||||
'version': '1.0.0',
|
||||
'database': 'connected'
|
||||
}), 200
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'status': 'unhealthy',
|
||||
'service': 'myp-backend',
|
||||
'timestamp': datetime.datetime.utcnow().isoformat() + 'Z',
|
||||
'error': str(e)
|
||||
}), 503
|
||||
|
||||
@app.route('/api/create-initial-admin', methods=['POST'])
|
||||
def create_initial_admin():
|
||||
|
Reference in New Issue
Block a user