Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from pymongo import MongoClient
|
| 3 |
+
import os
|
| 4 |
+
import certifi
|
| 5 |
+
from pydantic import BaseModel
|
| 6 |
+
from typing import List
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# Replace with your actual connection string
|
| 10 |
+
MONGO_URI = os.getenv("MONGO_URI")
|
| 11 |
+
# Connect to MongoDB Atlas
|
| 12 |
+
client = MongoClient(MONGO_URI, tls=True, tlsCAFile=certifi.where())
|
| 13 |
+
|
| 14 |
+
# Test the connection
|
| 15 |
+
try:
|
| 16 |
+
client.admin.command('ping')
|
| 17 |
+
print("Pinged your deployment. You successfully connected to MongoDB!")
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print(f"Error: {e}")
|