This commit is contained in:
2025-01-11 20:59:10 -05:00
parent 85a0d6bc62
commit 3c57f13557
18 changed files with 464 additions and 365 deletions

15
util.py
View File

@ -2,21 +2,25 @@
import logging
from fastapi import FastAPI, Response, HTTPException, Security
from fastapi import FastAPI, Response, HTTPException
class Utilities:
def __init__(self, app: FastAPI, constants):
"""API Utilities"""
def __init__(self, app: FastAPI, constants):
self.constants = constants
self.blocked_response_status = 422
self.blocked_response_content = None
self.app = app
def get_blocked_response(self, path: str | None = None):
def get_blocked_response(self, path: str | None = None): # pylint: disable=unused-argument
"""Get Blocked HTTP Response"""
logging.error("Rejected request: Blocked")
return Response(content=self.blocked_response_content,
status_code=self.blocked_response_status)
def get_no_endpoint_found(self, path: str | None = None):
def get_no_endpoint_found(self, path: str | None = None): # pylint: disable=unused-argument
"""Get 404 Response"""
logging.error("Rejected request: No such endpoint")
raise HTTPException(detail="Unknown endpoint", status_code=404)
@ -48,5 +52,4 @@ class Utilities:
return False
# print("Auth succeeded")
return True
return True