From cd023253ea23bed774b07d0fedbd163b73ab6abb Mon Sep 17 00:00:00 2001 From: MathiasDPX Date: Mon, 30 Dec 2024 03:31:25 +0100 Subject: [PATCH] Move log function to async --- app.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 15c6904..c84fd33 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ from flask import Flask, render_template, request from datetime import timedelta from dotenv import load_dotenv +from threading import Thread from os import getenv import monitoring import html @@ -86,11 +87,11 @@ def home(): if delta > 6: delta = 6 if delta < 0: delta = 0 - monitoring.log( - ip=request.environ.get("HTTP_X_FORWARDED_FOR", request.remote_addr), - useragent=request.headers.get('User-Agent'), - day=delta - ) + Thread(target=monitoring.log, kwargs={ + 'ip': request.environ.get("HTTP_X_FORWARDED_FOR", request.remote_addr), + 'useragent': request.headers.get('User-Agent'), + 'day': delta + }).start() dates = []