Update app.py
Browse files
app.py
CHANGED
@@ -11,24 +11,46 @@ import numpy as np
|
|
11 |
from dotenv import load_dotenv
|
12 |
load_dotenv()
|
13 |
|
|
|
|
|
|
|
|
|
14 |
# Azure Cosmos DB configuration
|
15 |
-
cosmos_endpoint = "COSMOS_ENDPOINT"
|
16 |
-
cosmos_key = "COSMOS_KEY"
|
17 |
-
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# MongoDB API configuration for text analysis results
|
24 |
-
mongo_connection_string = "MONGODB_CONNECTION_STRING"
|
25 |
-
|
26 |
-
|
27 |
-
analysis_collection = mongo_db['text_analysis']
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
# Configure the page to use the full width
|
34 |
st.set_page_config(
|
|
|
11 |
from dotenv import load_dotenv
|
12 |
load_dotenv()
|
13 |
|
14 |
+
from modules.auth import clean_and_validate_key, register_user, authenticate_user, get_user_role
|
15 |
+
from modules.morpho_analysis import get_repeated_words_colors, highlight_repeated_words, POS_COLORS, POS_TRANSLATIONS
|
16 |
+
from modules.syntax_analysis import visualize_syntax
|
17 |
+
|
18 |
# Azure Cosmos DB configuration
|
19 |
+
cosmos_endpoint = os.environ.get("COSMOS_ENDPOINT")
|
20 |
+
cosmos_key = os.environ.get("COSMOS_KEY")
|
|
|
21 |
|
22 |
+
if not cosmos_endpoint or not cosmos_key:
|
23 |
+
raise ValueError("Las variables de entorno COSMOS_ENDPOINT y COSMOS_KEY deben estar configuradas")
|
24 |
+
|
25 |
+
try:
|
26 |
+
cosmos_key = clean_and_validate_key(cosmos_key)
|
27 |
+
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
28 |
+
|
29 |
+
# SQL API database for user management
|
30 |
+
user_database = cosmos_client.get_database_client("user_database")
|
31 |
+
user_container = user_database.get_container_client("users")
|
32 |
+
|
33 |
+
print("Conexi贸n a Cosmos DB SQL API exitosa")
|
34 |
+
except Exception as e:
|
35 |
+
print(f"Error al conectar con Cosmos DB SQL API: {str(e)}")
|
36 |
+
raise
|
37 |
|
38 |
# MongoDB API configuration for text analysis results
|
39 |
+
mongo_connection_string = os.environ.get("MONGODB_CONNECTION_STRING")
|
40 |
+
if not mongo_connection_string:
|
41 |
+
raise ValueError("La variable de entorno MONGODB_CONNECTION_STRING debe estar configurada")
|
|
|
42 |
|
43 |
+
try:
|
44 |
+
mongo_client = MongoClient(mongo_connection_string)
|
45 |
+
mongo_db = mongo_client['aideatext_db']
|
46 |
+
analysis_collection = mongo_db['text_analysis']
|
47 |
+
|
48 |
+
# Prueba de conexi贸n
|
49 |
+
mongo_client.server_info()
|
50 |
+
print("Conexi贸n a MongoDB API exitosa")
|
51 |
+
except Exception as e:
|
52 |
+
print(f"Error al conectar con MongoDB API: {str(e)}")
|
53 |
+
raise
|
54 |
|
55 |
# Configure the page to use the full width
|
56 |
st.set_page_config(
|