feat: README-Anzeige und Code-Statistiken aktualisiert
This commit is contained in:
52
app.py
52
app.py
@@ -10,6 +10,7 @@ from functools import wraps
|
||||
from contextlib import contextmanager
|
||||
import time
|
||||
import threading
|
||||
import markdown2
|
||||
|
||||
app = Flask(__name__, static_folder='static')
|
||||
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'dev')
|
||||
@@ -394,6 +395,57 @@ def get_orte():
|
||||
logger.error(f"Fehler beim Abrufen der Orte: {str(e)}")
|
||||
return jsonify([])
|
||||
|
||||
@app.route('/upload', methods=['GET', 'POST'])
|
||||
def upload():
|
||||
if not session.get('logged_in'):
|
||||
return redirect(url_for('login'))
|
||||
|
||||
if request.method == 'POST':
|
||||
if request.form.get('password') != os.environ.get('UPLOAD_PASSWORD'):
|
||||
return render_template('upload.html', error="Falsches Passwort", version=app.config['VERSION'])
|
||||
|
||||
if 'customers_snk' not in request.files or 'customers' not in request.files:
|
||||
return render_template('upload.html', error="Bitte beide CSV-Dateien auswählen", version=app.config['VERSION'])
|
||||
|
||||
customers_snk = request.files['customers_snk']
|
||||
customers = request.files['customers']
|
||||
|
||||
if customers_snk.filename == '' or customers.filename == '':
|
||||
return render_template('upload.html', error="Keine Datei ausgewählt", version=app.config['VERSION'])
|
||||
|
||||
if not customers_snk.filename.endswith('.csv') or not customers.filename.endswith('.csv'):
|
||||
return render_template('upload.html', error="Nur CSV-Dateien sind erlaubt", version=app.config['VERSION'])
|
||||
|
||||
try:
|
||||
# Speichere die Dateien
|
||||
customers_snk.save('data/customers_snk.csv')
|
||||
customers.save('data/customers.csv')
|
||||
|
||||
# Importiere die Daten in die Datenbank
|
||||
import_csv('data/customers_snk.csv', 'snk')
|
||||
import_csv('data/customers.csv', 'medisoft')
|
||||
|
||||
return render_template('upload.html', success="Dateien erfolgreich hochgeladen und importiert", version=app.config['VERSION'])
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler beim Upload: {str(e)}")
|
||||
return render_template('upload.html', error=f"Fehler beim Upload: {str(e)}", version=app.config['VERSION'])
|
||||
|
||||
return render_template('upload.html', version=app.config['VERSION'])
|
||||
|
||||
@app.route('/readme')
|
||||
def readme():
|
||||
if not session.get('logged_in'):
|
||||
return redirect(url_for('login'))
|
||||
|
||||
try:
|
||||
with open('README.md', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
html_content = markdown2.markdown(content, extras=['fenced-code-blocks', 'tables'])
|
||||
return render_template('readme.html', content=html_content, version=app.config['VERSION'])
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler beim Lesen der README: {str(e)}")
|
||||
return render_template('readme.html', error="Fehler beim Lesen der README", version=app.config['VERSION'])
|
||||
|
||||
def init_app(app):
|
||||
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
||||
with app.app_context():
|
||||
|
Reference in New Issue
Block a user