File size: 1,096 Bytes
1c611eb 264072c 1c611eb 264072c 1c611eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import os
from pymongo.mongo_client import MongoClient
import streamlit as st
from streamlit_option_menu import option_menu
import pandas as pd
uri = os.environ["MONGO_CONNECTION_STRING"]
client = MongoClient(uri, tlsCertificateKeyFile="cert/cert.pem")
db = client["myapp"]
col = db["users"]
try:
client.admin.command('ping')
print("Connection Established!")
except Exception as e:
print(e)
def create_rem():
remmsg = st.text_input("What do you want to be reminded about")
date = str(st.date_input("When do you want to be reminded"))
time = str(st.time_input("At what time do you want to be reminded"))
newrem = {
"message": remmsg,
"date": date,
"time": time
}
col.insert_one(newrem)
def view_rem():
allrem = list(col.find())
df = pd.DataFrame(allrem)
st.dataframe(df)
def main():
with st.sidebar:
selected = option_menu(None, ["Create Reminder", "View Reminders"])
if selected == "Create Reminder":
create_rem()
elif selected == "View Reminders":
view_rem()
main()
|