955bc9a7bf
- auth/login.py: guard against missing JSON body (get_json silent=True, empty-string check) - app.py: replace infinite redirect with 404 for unknown /api/* and /setup/* paths - tools/jwtdecoder.py: add algorithms list to jwt.decode() for PyJWT 2.x compatibility - util/setup_routes.py: call reset_pool() after save_config() so pool re-initialises with new DB credentials - util/logger.py: set ERROR level on error.log handler so it no longer receives INFO/WARNING messages - LoginForm.jsx: remove dead navigate() call that was immediately overridden by window.location.href - main.jsx: remove base.css, dark.css, light.css that were already imported in App.jsx (duplicate imports) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
62 lines
1.8 KiB
Python
62 lines
1.8 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,
|
|
hasher_blueprint,
|
|
base64_blueprint,
|
|
jwt_decoder_blueprint,
|
|
passwordgen_blueprint,
|
|
timestamp_blueprint,
|
|
textdiff_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(hasher_blueprint)
|
|
app.register_blueprint(base64_blueprint)
|
|
app.register_blueprint(jwt_decoder_blueprint)
|
|
app.register_blueprint(passwordgen_blueprint)
|
|
app.register_blueprint(timestamp_blueprint)
|
|
app.register_blueprint(textdiff_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'):
|
|
from flask import abort
|
|
abort(404)
|
|
|
|
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)
|