Spaces:
Runtime error
Runtime error
updates app
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from fastapi import Request, HTTPException
|
|
4 |
from neural_searcher import NeuralSearcher
|
5 |
from huggingface_hub import login
|
6 |
from config import HUGGING_FACE_API_KEY, COLLECTION_NAME, API_KEY
|
|
|
7 |
|
8 |
login(HUGGING_FACE_API_KEY)
|
9 |
|
@@ -25,4 +26,11 @@ async def api_key_authentication(request: Request, call_next):
|
|
25 |
raise HTTPException(status_code=401, detail="Unauthorized: Invalid API Key")
|
26 |
|
27 |
response = await call_next(request)
|
28 |
-
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from neural_searcher import NeuralSearcher
|
5 |
from huggingface_hub import login
|
6 |
from config import HUGGING_FACE_API_KEY, COLLECTION_NAME, API_KEY
|
7 |
+
from fastapi.responses import JSONResponse
|
8 |
|
9 |
login(HUGGING_FACE_API_KEY)
|
10 |
|
|
|
26 |
raise HTTPException(status_code=401, detail="Unauthorized: Invalid API Key")
|
27 |
|
28 |
response = await call_next(request)
|
29 |
+
return response
|
30 |
+
|
31 |
+
@app.exception_handler(HTTPException)
|
32 |
+
async def http_exception_handler(request: Request, exc: HTTPException):
|
33 |
+
return JSONResponse(
|
34 |
+
status_code=exc.status_code,
|
35 |
+
content={"message": exc.detail},
|
36 |
+
)
|