Spaces:
Sleeping
Sleeping
Commit
·
c55bc6a
1
Parent(s):
a8cbb3f
revert fix tries
Browse files
main.py
CHANGED
@@ -17,25 +17,17 @@ app = FastAPI()
|
|
17 |
|
18 |
image_size = 256
|
19 |
hf_token = os.environ.get("api_read")
|
20 |
-
|
21 |
VALID_API_KEYS = os.environ.get("api_key")
|
22 |
|
23 |
|
24 |
@app.middleware("http")
|
25 |
async def verify_api_key(request, call_next):
|
26 |
-
|
27 |
-
if
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
else:
|
33 |
-
response = await call_next(request)
|
34 |
-
return response
|
35 |
-
|
36 |
-
|
37 |
-
print(hf_token)
|
38 |
-
print(VALID_API_KEYS)
|
39 |
|
40 |
models_locations = [
|
41 |
{
|
|
|
17 |
|
18 |
image_size = 256
|
19 |
hf_token = os.environ.get("api_read")
|
|
|
20 |
VALID_API_KEYS = os.environ.get("api_key")
|
21 |
|
22 |
|
23 |
@app.middleware("http")
|
24 |
async def verify_api_key(request, call_next):
|
25 |
+
api_key = request.headers.get("x-api-key")
|
26 |
+
if api_key is None or api_key not in VALID_API_KEYS:
|
27 |
+
raise HTTPException(status_code=403, detail="Unauthorized")
|
28 |
+
response = await call_next(request)
|
29 |
+
return response
|
30 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
models_locations = [
|
33 |
{
|