Spaces:
Sleeping
Sleeping
updates app
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ app = FastAPI()
|
|
| 12 |
|
| 13 |
neural_searcher = NeuralSearcher(collection_name=COLLECTION_NAME)
|
| 14 |
|
|
|
|
|
|
|
| 15 |
@app.get("/api/search")
|
| 16 |
async def search(q: str):
|
| 17 |
xss = nh3.clean(q)
|
|
@@ -22,8 +24,8 @@ async def search(q: str):
|
|
| 22 |
@app.middleware("http")
|
| 23 |
async def api_key_authentication(request: Request, call_next):
|
| 24 |
api_key = request.headers.get("X-API-KEY")
|
| 25 |
-
print(api_key + "###" +
|
| 26 |
-
if api_key !=
|
| 27 |
return JSONResponse(
|
| 28 |
status_code=403,
|
| 29 |
content={"message": "Forbidden."}
|
|
|
|
| 12 |
|
| 13 |
neural_searcher = NeuralSearcher(collection_name=COLLECTION_NAME)
|
| 14 |
|
| 15 |
+
ALLOWED_API_KEY = API_KEY
|
| 16 |
+
|
| 17 |
@app.get("/api/search")
|
| 18 |
async def search(q: str):
|
| 19 |
xss = nh3.clean(q)
|
|
|
|
| 24 |
@app.middleware("http")
|
| 25 |
async def api_key_authentication(request: Request, call_next):
|
| 26 |
api_key = request.headers.get("X-API-KEY")
|
| 27 |
+
print(api_key + "###" + str(ALLOWED_API_KEY))
|
| 28 |
+
if api_key != ALLOWED_API_KEY:
|
| 29 |
return JSONResponse(
|
| 30 |
status_code=403,
|
| 31 |
content={"message": "Forbidden."}
|