| 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() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|