Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,17 @@ from pymongo import MongoClient
|
|
5 |
from datetime import datetime
|
6 |
from pathlib import Path
|
7 |
from document_chunker import DocumentChunker
|
|
|
8 |
|
9 |
# === MongoDB connection via Hugging Face secrets ===
|
10 |
-
|
|
|
|
|
|
|
11 |
db_name = os.environ.get("MONGO_DB", "grant_docs")
|
12 |
-
|
|
|
|
|
13 |
db = client[db_name]
|
14 |
|
15 |
# === Streamlit UI ===
|
|
|
5 |
from datetime import datetime
|
6 |
from pathlib import Path
|
7 |
from document_chunker import DocumentChunker
|
8 |
+
from urllib.parse import quote_plus
|
9 |
|
10 |
# === MongoDB connection via Hugging Face secrets ===
|
11 |
+
user = quote_plus(os.getenv("MONGO_USER"))
|
12 |
+
password = quote_plus(os.getenv("MONGO_PASS"))
|
13 |
+
cluster = os.getenv("MONGO_CLUSTER")
|
14 |
+
# db_name = "grant_docs"
|
15 |
db_name = os.environ.get("MONGO_DB", "grant_docs")
|
16 |
+
mongo_uri = f"mongodb+srv://{user}:{password}@{cluster}/{db_name}?retryWrites=true&w=majority&tls=true&tlsAllowInvalidCertificates=true"
|
17 |
+
# mongo_uri = os.environ["MONGO_URI"]
|
18 |
+
client = MongoClient(mongo_uri, tls=True, tlsAllowInvalidCertificates=True, serverSelectionTimeoutMS=20000)
|
19 |
db = client[db_name]
|
20 |
|
21 |
# === Streamlit UI ===
|