Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
from streamlit_option_menu import option_menu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
option_menu(None, ["Home", "About Us", "Logout"], orientation="horizontal")
|
|
|
1 |
import streamlit as st
|
2 |
from streamlit_option_menu import option_menu
|
3 |
+
import os
|
4 |
+
from pymongo.mongo_client import MongoClient
|
5 |
+
from pymongo.server_api import ServerApi
|
6 |
+
|
7 |
+
uri = os.environ["MONGO_CONNECTION_STRING"]
|
8 |
+
|
9 |
+
# Create a new client and connect to the server
|
10 |
+
client = MongoClient(uri, server_api=ServerApi('1'))
|
11 |
+
|
12 |
+
# Send a ping to confirm a successful connection
|
13 |
+
try:
|
14 |
+
client.admin.command('ping')
|
15 |
+
print("Pinged your deployment. You successfully connected to MongoDB!")
|
16 |
+
except Exception as e:
|
17 |
+
print(e)
|
18 |
|
19 |
option_menu(None, ["Home", "About Us", "Logout"], orientation="horizontal")
|