80ec5eca7b
- Move SECRET_KEY out of docker-compose into .env (env_file), add .env.example - Add flask-limiter with 10 req/min on login route; introduce util/limiter.py - Replace direct mysql.connector.connect() calls with MySQLConnectionPool via util/db_pool.py - Fix deprecated datetime.utcnow() -> datetime.now(timezone.utc) in auth/login.py - Remove dead /api/scripts 410 route from admin.py - Add MD5 security warning in Md5Tool.jsx - Add ErrorBoundary component and wrap App.jsx - Expand README with setup guide, screenshot and project structure Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import os
|
|
import sys
|
|
if __name__ != '__main__':
|
|
import sys
|
|
sys.path.append(os.path.dirname(__file__))
|
|
|
|
from flask import Flask, send_from_directory, redirect
|
|
from util.logger import logger
|
|
from util.db_config import is_configured, load_config, test_connection
|
|
from util.setup_routes import setup_blueprint
|
|
from util.limiter import limiter
|
|
from auth import auth_bp
|
|
from tools import md5_blueprint
|
|
from admin import admin_bp
|
|
|
|
app = Flask(__name__, template_folder="templates")
|
|
limiter.init_app(app)
|
|
|
|
# Blueprints registrieren
|
|
app.register_blueprint(setup_blueprint)
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(md5_blueprint)
|
|
app.register_blueprint(admin_bp)
|
|
|
|
# 🌐 React-Frontend ausliefern
|
|
@app.route('/', defaults={'path': ''})
|
|
@app.route('/<path:path>')
|
|
def serve_frontend(path):
|
|
if not is_configured() or not test_connection(load_config()):
|
|
return redirect('/setup')
|
|
|
|
if path.startswith('setup') or path.startswith('api'):
|
|
return redirect(f'/{path}')
|
|
|
|
dist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'frontend', 'dist'))
|
|
file_path = os.path.join(dist_dir, path)
|
|
|
|
if path and os.path.exists(file_path):
|
|
return send_from_directory(dist_dir, path)
|
|
else:
|
|
return send_from_directory(dist_dir, 'index.html')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
os.makedirs("config", exist_ok=True)
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|