Mikelue's picture
Add 2 files
211b5f0
import gradio
import random
import numpy
# function for generating random integers
def generate_random_integers(n):
return numpy.random.randint(1,100, n)
# function for displaying random integers
def display_random_integers(integers):
# create a Dataframe to display the integers
columns = ["Number"]
df = pandas.DataFrame(columns=columns)
for i in integers:
df = df.append({"Number": i}, ignore_index=True)
return df
#define the main step function
def todo_list_app(num_items, items):
# create a Dataframe to display the items
columns = ["Task", "Completion Status"]
df = pandas.DataFrame(columns=columns)
for i in range(num_items):
item = items[i]
due_date = item["due_date"]
completion_status = item["completion_status"]
df = df.append({"Task": due_date, "Completion Status": completion_status}, ignore_index=True)
return df
#define the function for progressive web app
def progressive_web_app(num_items, items):
return todo_list_app(num_items, items)
#create the interface
interface = gradio.Interface(
fn=todo_list_app,
inputs=[
"number",
gradio.Radio(["buy groceries", "take dog for a walk", "learn gradio", "write a note", "workout", "learn a new skill"]),
gradio.Dataframe(
headers=["Item", "Due Date", "Completion Status"],
datatype=["str", "str", "bool"],
label="To-Do List",
),
],
outputs="number",
examples=[
[5, "buy groceries", [["buy groceries", "due today", False], ["take dog for a walk", "due tomorrow", False], ["learn gradio", "due next week", False], ["write a note", "due in a few days", False], ["workout", "due tomorrow", False]]],
[3, "buy groceries", [["buy groceries", "due today", False], ["take dog for a walk", "due tomorrow", False], ["learn gradio", "due next week", False]]],
],
)
#create the progressive web app interface
interface.launch(kind="pwa")