Spaces:
Runtime error
Runtime error
Commit ·
2335e48
1
Parent(s): 3f30e0e
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,23 +3,20 @@ import torch
|
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
| 5 |
import os
|
|
|
|
| 6 |
from google.cloud import storage
|
| 7 |
import pinecone
|
| 8 |
import json
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"token_uri": os.environ["token_uri"],
|
| 20 |
-
"auth_provider_x509_cert_url": os.environ["auth_provider_x509_cert_url"],
|
| 21 |
-
"client_x509_cert_url": os.environ["client_x509_cert_url"]
|
| 22 |
-
}
|
| 23 |
with open('cloud-storage.json', 'w') as fp:
|
| 24 |
fp.write(json.dumps(G_API, indent=4))
|
| 25 |
del G_API
|
|
|
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
| 5 |
import os
|
| 6 |
+
from cryptography.fernet import Fernet
|
| 7 |
from google.cloud import storage
|
| 8 |
import pinecone
|
| 9 |
import json
|
| 10 |
|
| 11 |
+
# decrypt Storage Cloud credentials
|
| 12 |
+
fernet = Fernet(os.environ['DECRYPTION_KEY'])
|
| 13 |
+
|
| 14 |
+
with open('cloud-storage.encrypted', 'rb') as fp:
|
| 15 |
+
encrypted = fp.read()
|
| 16 |
+
creds = json.loads(fernet.decrypt(encrypted).decode())
|
| 17 |
+
# then save creds to file
|
| 18 |
+
with open('cloud-storage.json', 'w', encoding='utf-8') as fp:
|
| 19 |
+
fp.write(json.dumps(creds, indent=4))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
with open('cloud-storage.json', 'w') as fp:
|
| 21 |
fp.write(json.dumps(G_API, indent=4))
|
| 22 |
del G_API
|