From 7311748c1fccd34ce4e692b85e1002120b831a71 Mon Sep 17 00:00:00 2001 From: deffcolony <61471128+deffcolony@users.noreply.github.com> Date: Fri, 18 Aug 2023 23:23:14 +0200 Subject: [PATCH 1/3] Python Colorama for some console prints --- server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index fddf77f..2a3029f 100644 --- a/server.py +++ b/server.py @@ -554,11 +554,11 @@ if args.secure: with open("api_key.txt", "w") as txt: txt.write(api_key) - print(f"Your API key is {api_key}") + print(f"{Fore.YELLOW}{Style.BRIGHT}Your API key is {api_key}{Style.RESET_ALL}") elif args.share and args.secure != True: - print("WARNING: This instance is publicly exposed without an API key! It is highly recommended to restart with the \"--secure\" argument!") + print(f"{Fore.RED}{Style.BRIGHT}WARNING: This instance is publicly exposed without an API key! It is highly recommended to restart with the \"--secure\" argument!{Style.RESET_ALL}") else: - print("No API key given because you are running locally.") + print(f"{Fore.YELLOW}{Style.BRIGHT}No API key given because you are running locally.{Style.RESET_ALL}") def is_authorize_ignored(request): @@ -1122,7 +1122,7 @@ if args.share: cloudflare = _run_cloudflared(port, metrics_port) else: cloudflare = _run_cloudflared(port) - print("\x1b[32mRunning on", cloudflare + "\x1b[0m") + print(f"{Fore.GREEN}{Style.NORMAL}Running on: {cloudflare}{Style.RESET_ALL}") ignore_auth.append(tts_play_sample) app.run(host=host, port=port) From 84d11246a844c5a3de4915e729178edec91db733 Mon Sep 17 00:00:00 2001 From: deffcolony <61471128+deffcolony@users.noreply.github.com> Date: Fri, 18 Aug 2023 23:30:33 +0200 Subject: [PATCH 2/3] Update server.py --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 2a3029f..9761aaf 100644 --- a/server.py +++ b/server.py @@ -579,7 +579,7 @@ def before_request(): # The options check is required so CORS doesn't get angry try: if request.method != 'OPTIONS' and args.secure and is_authorize_ignored(request) == False and getattr(request.authorization, 'token', '') != api_key: - print(f"WARNING: Unauthorized API key access from {request.remote_addr}") + print(f"{Fore.RED}{Style.NORMAL}WARNING: Unauthorized API key access from {request.remote_addr}{Style.RESET_ALL}") response = jsonify({ 'error': '401: Invalid API key' }) response.status_code = 401 return response From 4bc0238f5cb9bc7883a9b1b120aa7eacf560b3cb Mon Sep 17 00:00:00 2001 From: deffcolony <61471128+deffcolony@users.noreply.github.com> Date: Fri, 18 Aug 2023 23:31:42 +0200 Subject: [PATCH 3/3] Update server.py --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 2a3029f..9761aaf 100644 --- a/server.py +++ b/server.py @@ -579,7 +579,7 @@ def before_request(): # The options check is required so CORS doesn't get angry try: if request.method != 'OPTIONS' and args.secure and is_authorize_ignored(request) == False and getattr(request.authorization, 'token', '') != api_key: - print(f"WARNING: Unauthorized API key access from {request.remote_addr}") + print(f"{Fore.RED}{Style.NORMAL}WARNING: Unauthorized API key access from {request.remote_addr}{Style.RESET_ALL}") response = jsonify({ 'error': '401: Invalid API key' }) response.status_code = 401 return response