Skip to content

Commit

Permalink
Added stats per request
Browse files Browse the repository at this point in the history
  • Loading branch information
Red_wolf2467 committed Nov 17, 2024
1 parent 06aa2c8 commit d600c07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pytest
colorama
Levenshtein
anyio
pytest-asyncio
pytest-asyncio
uuid
20 changes: 17 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from quart import Quart, request
from colorama import Fore, Style
from Levenshtein import distance
import hashlib
import hashlib, time, uuid

print(Fore.MAGENTA, "Programm developed by Red_wolf2467")
print(Fore.MAGENTA, "Starting up chatfilter server...")
Expand Down Expand Up @@ -89,6 +89,8 @@ def hash_string(string: str):

@server.route("/chatfilter")
async def check_message():
start_time = time.time()
logger.info(f"Start processing order number chatfilter-{uuid.uuid1}")
data = await request.get_json()
badwords = load_data("json/badwords.json")
goodwords = load_data("json/goodwords.json")
Expand All @@ -99,11 +101,19 @@ async def check_message():
message = data["message"]
results = check_chatfilter(message, badwords, goodwords)

end_time = time.time()
processing_time = end_time - start_time
logger.info(f"Processing of order number chatfilter-{id} in {processing_time}s completed.")

return results


@server.route("/user")
async def check_user():
print()
start_time = time.time()
id = uuid.uuid1
logger.info(f"Start processing order number user-{id}")
data = await request.get_json()
key_hash_list = load_data("json/key_hash.json")
ids_list = load_data("json/ids.json")
Expand All @@ -114,6 +124,10 @@ async def check_user():

result = check_user_db(int(user_id), ids_list)

end_time = time.time()
processing_time = end_time - start_time
logger.info(f"Processing of order number user-{id} in {processing_time}s completed.")

return result


Expand All @@ -136,11 +150,11 @@ async def add_flagged_user():
"id": int(user_id),
"name": str(user_name),
"reason": str(reason),
"flagged": bool(True)
"flagged": bool(True),
}
save_data("json/ids.json", ids_list)
return {"success": True, "message": "Used was flagged"}


@server.route("/deflag_user")
async def remove_flagged_user():
Expand Down

0 comments on commit d600c07

Please sign in to comment.