MLRG_Frontend / app.py
Vish2005's picture
Update app.py
10bc8b4
raw
history blame
1.16 kB
import gradio as gr
from queue import PriorityQueue
from datetime import datetime
pq = PriorityQueue(maxsize = None)
date_format = '%m-%d-%Y at %H:%M'
def writer(pair):
final = pair[1] + ' is due on '
final += f'{pair[0].month:02}-{pair[0].day:02}-{pair[0].year} at '
final += f'{pair[0].hour:02}:{pair[0].minute:02}'
return final
def string_rep(pq):
work = ""
for element in pq.queue:
work += writer(element) + '\n'
return work
def add_elem(date_str, item_name):
cur_date = datetime.strptime(date_str, date_format)
pq.put((cur_date, item_name))
return string_rep(pq)
def pop():
pq.get()
return string_rep(pq)
datebox = gr.Textbox(label="Enter your date here:", placeholder="MM-DD-YYYY at HH:MM")
hwbox = gr.Textbox(label="Enter your assignment name here:", placeholder="Homework")
def tester(str1, str2):
cur_date = datetime.strptime(date_str, date_format)
return str(cur_date.month)
iface = gr.Interface(
fn=tester,
inputs=[datebox, hwbox],
outputs="text",
title="Add Work",
description="Homework Prioritzer",
)
iface.launch()