Spaces:
Runtime error
Runtime error
import streamlit as st | |
from streamlit_option_menu import option_menu | |
import os | |
from pymongo.mongo_client import MongoClient | |
# from pymongo.server_api import ServerApi | |
uri = os.environ["MONGO_CONNECTION_STRING"] | |
# Create a new client and connect to the server | |
client = MongoClient(uri, ssl=False, tls=False) | |
db = client["myapp"] | |
col = db["users"] | |
newuser = { | |
"username": "John", | |
"password": "sdgsg" | |
} | |
col.insert_one(newuser) | |
print("done!") | |
# Send a ping to confirm a successful connection | |
try: | |
client.admin.command('ping') | |
print("Pinged your deployment. You successfully connected to MongoDB!") | |
except Exception as e: | |
print(e) | |
option_menu(None, ["Home", "About Us", "Logout"], orientation="horizontal") |