Hello! This is my first time on the forum and I am pretty new to python. After learning all of the basics, I have created a program that helps give me a visual countdown of my school periods. I want to make this into a basic web application using flask, but I do not know how I should go about doing that. While looking up flask tutorials it seems that I have to make my program into a function somehow so that I can see the countdown on the web application. How can I do this? Help would be much appreciated!
My current program:
import time
normal_school_time_table = (59, 5, 59, 7, 59, 5, 59, 30, 5, 59, 5, 59)
thursday_school_time_table = (47, 5, 47, 7, 47, 5, 47, 30, 5, 47, 5, 47)
normal_days = ["Monday", "Tuesday", "Wednesday", "Friday"]
short_day = "Thursday"
try:
while True:
week_day = time.strftime("%A", time.localtime())
current_time = time.strftime("%H:%M", time.localtime())
if week_day in normal_days and current_time == "8:30":
print("It is a normal week day!")
for period in normal_school_time_table:
if period < 10:
print(f'0{period}:00')
else:
print(f'{period}:00')
time.sleep(1)
for minute in range(period - 1, -1, -1):
for second in range(59, -1, -1):
if second <= 9 < minute:
print(f'{minute}:0{second}')
elif second <= 9 and minute <= 9:
print(f'0{minute}:0{second}')
elif second > 9 >= minute:
print(f'0{minute}:{second}')
elif second > 9 and minute > 9:
print(f'{minute}:{second}')
time.sleep(1)
elif week_day == short_day and current_time == "8:30":
print("It is Thursday, a short day!")
for period in thursday_school_time_table:
if period < 10:
print(f'0{period}:00')
else:
print(f'{period}:00')
time.sleep(1)
for minute in range(period - 1, -1, -1):
for second in range(59, -1, -1):
if second <= 9 < minute:
print(f'{minute}:0{second}')
elif second <= 9 and minute <= 9:
print(f'0{minute}:0{second}')
elif second > 9 >= minute:
print(f'0{minute}:{second}')
elif second > 9 and minute > 9:
print(f'{minute}:{second}')
time.sleep(1)
except KeyboardInterrupt:
print("Program stopped manually")