modified: app.py
This commit is contained in:
31
app.py
31
app.py
@@ -10,10 +10,35 @@ import psutil
|
|||||||
import mysql.connector
|
import mysql.connector
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
|
import logging
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = os.getenv("FLASK_SECRET_KEY")
|
app.secret_key = os.getenv("FLASK_SECRET_KEY")
|
||||||
|
|
||||||
|
# Disable Flask/Werkzeug logging for static files and 304 responses
|
||||||
|
logging.getLogger('werkzeug').setLevel(logging.ERROR)
|
||||||
|
app.logger.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
# Configure custom logging to only show important messages
|
||||||
|
log = logging.getLogger('werkzeug')
|
||||||
|
log.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
# Override Flask's logger to filter out static file requests
|
||||||
|
class NoStaticFilter(logging.Filter):
|
||||||
|
def filter(self, record):
|
||||||
|
# Filter out static file requests and 304 responses
|
||||||
|
if hasattr(record, 'msg'):
|
||||||
|
msg = str(record.msg)
|
||||||
|
if '/static/' in msg and ('304' in msg or '200' in msg):
|
||||||
|
return False
|
||||||
|
if 'GET /static/' in msg:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Apply filter to werkzeug logger
|
||||||
|
werkzeug_logger = logging.getLogger('werkzeug')
|
||||||
|
werkzeug_logger.addFilter(NoStaticFilter())
|
||||||
|
|
||||||
LOG_FILE_PATH = os.path.join("logs", f"{datetime.now().strftime('%Y-%m-%d')}.log")
|
LOG_FILE_PATH = os.path.join("logs", f"{datetime.now().strftime('%Y-%m-%d')}.log")
|
||||||
app.config["SESSION_TYPE"] = "filesystem" # Oder 'redis' für Redis-basierte Speicherung
|
app.config["SESSION_TYPE"] = "filesystem" # Oder 'redis' für Redis-basierte Speicherung
|
||||||
Session(app)
|
Session(app)
|
||||||
@@ -783,4 +808,10 @@ def stop():
|
|||||||
return redirect(url_for("landing_page"))
|
return redirect(url_for("landing_page"))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Disable default Flask logging for static files
|
||||||
|
app.logger.disabled = True
|
||||||
|
log = logging.getLogger('werkzeug')
|
||||||
|
log.disabled = True
|
||||||
|
|
||||||
|
# Start app with minimal logging
|
||||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user