Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
from huggingface_hub import hf_api
|
| 5 |
+
|
| 6 |
+
# Alarm Notification
|
| 7 |
+
def alarm_notification():
|
| 8 |
+
# Use Hugging Face model for notifications (Optional)
|
| 9 |
+
st.write("⏰ Alarm! Time to wake up!")
|
| 10 |
+
st.balloons()
|
| 11 |
+
|
| 12 |
+
# Set the alarm functionality
|
| 13 |
+
def set_alarm():
|
| 14 |
+
st.header("Set Alarm")
|
| 15 |
+
|
| 16 |
+
# Get user input for the alarm time
|
| 17 |
+
alarm_time_input = st.text_input("Enter alarm time (HH:MM:SS format)", "00:00:00")
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
alarm_time = datetime.strptime(alarm_time_input, "%H:%M:%S").time()
|
| 21 |
+
except ValueError:
|
| 22 |
+
st.error("Invalid time format. Please use HH:MM:SS format.")
|
| 23 |
+
return
|
| 24 |
+
|
| 25 |
+
st.write(f"Alarm set for {alarm_time_input}.")
|
| 26 |
+
|
| 27 |
+
while True:
|
| 28 |
+
# Get current time
|
| 29 |
+
current_time = datetime.now().time().strftime("%H:%M:%S")
|
| 30 |
+
|
| 31 |
+
# Compare the current time to the alarm time
|
| 32 |
+
if current_time == alarm_time_input:
|
| 33 |
+
alarm_notification()
|
| 34 |
+
break
|
| 35 |
+
time.sleep(1)
|
| 36 |
+
|
| 37 |
+
# Main Streamlit Interface
|
| 38 |
+
def main():
|
| 39 |
+
st.title("Hugging Face Alarm App")
|
| 40 |
+
|
| 41 |
+
set_alarm_button = st.button("Set Alarm")
|
| 42 |
+
|
| 43 |
+
if set_alarm_button:
|
| 44 |
+
set_alarm()
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
main()
|