From 18261b625b46875d9c7a99b8c75c453d5e179424 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 16 Jan 2024 10:24:30 +0100 Subject: [PATCH] Update main.py --- ollama_proxy_server/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ollama_proxy_server/main.py b/ollama_proxy_server/main.py index a589b8c..5f81706 100644 --- a/ollama_proxy_server/main.py +++ b/ollama_proxy_server/main.py @@ -44,19 +44,19 @@ def main(): authorized_users = get_authorized_users(args.users_list) class RequestHandler(BaseHTTPRequestHandler): - def add_access_log_entry(user, ip_address): + def add_access_log_entry(self, user, ip_address, access): log_file_path = Path(sys.argv[1]) if not log_file_path.exists(): with open(log_file_path, mode='w', newline='') as csvfile: - fieldnames = ['time_stamp', 'user_name', 'ip_address'] + fieldnames = ['time_stamp', 'user_name', 'ip_address','access'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() with open(log_file_path, mode='a', newline='') as csvfile: fieldnames = ['time_stamp', 'user_name', 'ip_address'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) - row = {'time_stamp': str(datetime.datetime.now()), 'user_name': user, 'ip_address': ip_address} + row = {'time_stamp': str(datetime.datetime.now()), 'user_name': user, 'ip_address': ip_address, 'access': access} writer.writerow(row) def _send_response(self, response): @@ -87,6 +87,7 @@ def main(): def proxy(self): if not self._validate_user_and_key(): ASCIIColors.red(f'User is not authorized') + # self.add_access_log_entry("unknown") self.send_response(403) self.end_headers() return