Spaces:
Running
Running
Change to use env instead
Browse files
app.py
CHANGED
@@ -13,18 +13,11 @@ from fastapi import FastAPI, status, HTTPException, Depends, UploadFile
|
|
13 |
from fastapi.middleware.gzip import GZipMiddleware
|
14 |
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
try:
|
19 |
-
with open(keys_file) as file:
|
20 |
-
keys = json.load(file)
|
21 |
-
except FileNotFoundError:
|
22 |
-
pass
|
23 |
|
24 |
def verify_credentials(credentials: str):
|
25 |
-
if
|
26 |
-
|
27 |
-
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
28 |
|
29 |
detection_model_file = os.path.abspath(os.path.join(os.getcwd(), "det.onnx"))
|
30 |
recognition_model_file = os.path.abspath(os.path.join(os.getcwd(), "rec.onnx"))
|
|
|
13 |
from fastapi.middleware.gzip import GZipMiddleware
|
14 |
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
15 |
|
16 |
+
keys = json.loads(os.getenv('KEYS'))
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def verify_credentials(credentials: str):
|
19 |
+
if not credentials in keys:
|
20 |
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
|
|
21 |
|
22 |
detection_model_file = os.path.abspath(os.path.join(os.getcwd(), "det.onnx"))
|
23 |
recognition_model_file = os.path.abspath(os.path.join(os.getcwd(), "rec.onnx"))
|
keys.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
["sk-5110bd57475c4784b4e1f00990a16871"]
|
|
|
|