cleanup
This commit is contained in:
15
util.py
15
util.py
@ -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
|
Reference in New Issue
Block a user