Spaces:
Runtime error
Runtime error
Add 2 files
Browse files
README.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
colorFrom: green
|
5 |
-
colorTo:
|
6 |
-
|
7 |
-
pinned: false
|
8 |
-
license: mit
|
9 |
-
---
|
10 |
-
|
11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
+
title: Todo List App using Gradio
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 3.39.0
|
6 |
+
app_file: app.py
|
7 |
+
emoji: π
|
8 |
colorFrom: green
|
9 |
+
colorTo: blue
|
10 |
+
---
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio
|
2 |
+
import random
|
3 |
+
import numpy
|
4 |
+
|
5 |
+
# function for generating random integers
|
6 |
+
def generate_random_integers(n):
|
7 |
+
return numpy.random.randint(1,100, n)
|
8 |
+
|
9 |
+
# function for displaying random integers
|
10 |
+
def display_random_integers(integers):
|
11 |
+
# create a Dataframe to display the integers
|
12 |
+
columns = ["Number"]
|
13 |
+
df = pandas.DataFrame(columns=columns)
|
14 |
+
for i in integers:
|
15 |
+
df = df.append({"Number": i}, ignore_index=True)
|
16 |
+
return df
|
17 |
+
|
18 |
+
#define the main step function
|
19 |
+
def todo_list_app(num_items, items):
|
20 |
+
# create a Dataframe to display the items
|
21 |
+
columns = ["Task", "Completion Status"]
|
22 |
+
df = pandas.DataFrame(columns=columns)
|
23 |
+
for i in range(num_items):
|
24 |
+
item = items[i]
|
25 |
+
due_date = item["due_date"]
|
26 |
+
completion_status = item["completion_status"]
|
27 |
+
df = df.append({"Task": due_date, "Completion Status": completion_status}, ignore_index=True)
|
28 |
+
return df
|
29 |
+
|
30 |
+
#define the function for progressive web app
|
31 |
+
def progressive_web_app(num_items, items):
|
32 |
+
return todo_list_app(num_items, items)
|
33 |
+
|
34 |
+
#create the interface
|
35 |
+
interface = gradio.Interface(
|
36 |
+
fn=todo_list_app,
|
37 |
+
inputs=[
|
38 |
+
"number",
|
39 |
+
gradio.Radio(["buy groceries", "take dog for a walk", "learn gradio", "write a note", "workout", "learn a new skill"]),
|
40 |
+
gradio.Dataframe(
|
41 |
+
headers=["Item", "Due Date", "Completion Status"],
|
42 |
+
datatype=["str", "str", "bool"],
|
43 |
+
label="To-Do List",
|
44 |
+
),
|
45 |
+
],
|
46 |
+
outputs="number",
|
47 |
+
examples=[
|
48 |
+
[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]]],
|
49 |
+
[3, "buy groceries", [["buy groceries", "due today", False], ["take dog for a walk", "due tomorrow", False], ["learn gradio", "due next week", False]]],
|
50 |
+
],
|
51 |
+
)
|
52 |
+
|
53 |
+
#create the progressive web app interface
|
54 |
+
interface.launch(kind="pwa")
|