-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
31 lines (24 loc) · 1.07 KB
/
app.py
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
import streamlit as st
from utils.ui import render_ui
from utils.helpers import trigger_github_action, convert_to_local_time
from db.mongo import add_user, add_or_update_preference, get_user_by_email
# Configuration
CITIES = ["Paris", "Aubervilliers", "Nanterre"]
def main():
_, station_name, time_slot, email, subscribe_button = render_ui(CITIES)
local_time_slot = convert_to_local_time(time_slot)
if subscribe_button:
try:
existing_user = get_user_by_email(email)
if not existing_user:
add_user(email, is_premium=False)
add_or_update_preference(email, station_name, local_time_slot)
if trigger_github_action(email, station_name, local_time_slot):
st.success(
f"Notification programmée pour {time_slot} à la station {station_name} pour l'adresse {email}!")
else:
st.error("Erreur lors du déclenchement de l'action GitHub.")
except Exception as e:
st.error(f"An error occurred: {e}")
if __name__ == "__main__":
main()