lianxu commited on
Commit
ea7ee05
·
1 Parent(s): b598c57

Change to use env instead

Browse files
Files changed (2) hide show
  1. app.py +3 -10
  2. keys.json +0 -1
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
- keys_file = os.path.abspath(os.path.join(os.getcwd(), "keys.json"))
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 'keys' in globals():
26
- if not credentials in keys:
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"]