Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,25 @@ 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, ssl=False, tls=False)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# Send a ping to confirm a successful connection
|
13 |
try:
|
14 |
client.admin.command('ping')
|
|
|
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, ssl=False, tls=False)
|
11 |
|
12 |
+
db = client["myapp"]
|
13 |
+
|
14 |
+
col = db["users"]
|
15 |
+
|
16 |
+
newuser = {
|
17 |
+
"username": "John",
|
18 |
+
"password": "sdgsg"
|
19 |
+
}
|
20 |
+
|
21 |
+
col.insert_one(newuser)
|
22 |
+
print("done!")
|
23 |
+
|
24 |
# Send a ping to confirm a successful connection
|
25 |
try:
|
26 |
client.admin.command('ping')
|