Spaces:
Sleeping
Sleeping
Commit
·
f0efd2a
1
Parent(s):
1f7f38a
Move keys to env
Browse files- old-app.py +4 -8
old-app.py
CHANGED
@@ -1,22 +1,18 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
from azure.storage.blob import BlobServiceClient
|
4 |
from azure.core.credentials import AzureKeyCredential
|
5 |
from azure.ai.translation.document import DocumentTranslationClient
|
6 |
|
7 |
# Azure Blob Storage connection strings
|
8 |
-
STORAGE_CONNECTION_STRING = 'DefaultEndpointsProtocol=https;AccountName=cbdtranslation;AccountKey=V4CBDnn6UH8PlybYGAbLUxejErCnDdxJWWcbMeM+HJB8S/zYDof/8EWAtG6latsG12fR2Q9NVf4l+ASt4ohA4g==;EndpointSuffix=core.windows.net'
|
9 |
|
10 |
# Container names
|
11 |
FIRST_CONTAINER_NAME = "source"
|
12 |
SECOND_CONTAINER_NAME = "target"
|
13 |
|
14 |
-
# Translator AI
|
15 |
-
AZURE_AI_TRANSLATOR_KEY = "26JrNtz5HvXYJ7zTL1MkmuRjTkAJ4EXx2gsHp6rj8pV9VIb4Q6TTJQQJ99AKACqBBLyXJ3w3AAAbACOGFu5N"
|
16 |
-
AZURE_AI_ENDPOINT_URL = "https://cbd-translation.cognitiveservices.azure.com/"
|
17 |
-
|
18 |
# Initialize Azure Blob Service Clients
|
19 |
-
blob_service_client = BlobServiceClient.from_connection_string(
|
20 |
|
21 |
# Function to upload file to Azure Storage
|
22 |
def upload_to_azure(blob_service_client, container_name, file, file_name):
|
@@ -36,8 +32,8 @@ def delete_from_azure(blob_service_client, container_name, file_name):
|
|
36 |
blob_client = container_client.get_blob_client(blob=file_name)
|
37 |
blob_client.delete_blob()
|
38 |
|
39 |
-
key = AZURE_AI_TRANSLATOR_KEY
|
40 |
-
endpoint = AZURE_AI_ENDPOINT_URL
|
41 |
|
42 |
sourceUri = "https://cbdtranslation.blob.core.windows.net/source"
|
43 |
targetUri = "https://cbdtranslation.blob.core.windows.net/target"
|
|
|
1 |
import streamlit as st
|
2 |
+
import os
|
3 |
|
4 |
from azure.storage.blob import BlobServiceClient
|
5 |
from azure.core.credentials import AzureKeyCredential
|
6 |
from azure.ai.translation.document import DocumentTranslationClient
|
7 |
|
8 |
# Azure Blob Storage connection strings
|
|
|
9 |
|
10 |
# Container names
|
11 |
FIRST_CONTAINER_NAME = "source"
|
12 |
SECOND_CONTAINER_NAME = "target"
|
13 |
|
|
|
|
|
|
|
|
|
14 |
# Initialize Azure Blob Service Clients
|
15 |
+
blob_service_client = BlobServiceClient.from_connection_string(os.environ["AZURE_STORAGE_CONNECTION_STRING"])
|
16 |
|
17 |
# Function to upload file to Azure Storage
|
18 |
def upload_to_azure(blob_service_client, container_name, file, file_name):
|
|
|
32 |
blob_client = container_client.get_blob_client(blob=file_name)
|
33 |
blob_client.delete_blob()
|
34 |
|
35 |
+
key = os.environ["AZURE_AI_TRANSLATOR_KEY"]
|
36 |
+
endpoint = os.environ["AZURE_AI_ENDPOINT_URL"]
|
37 |
|
38 |
sourceUri = "https://cbdtranslation.blob.core.windows.net/source"
|
39 |
targetUri = "https://cbdtranslation.blob.core.windows.net/target"
|