Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ repo = Repository(
|
|
| 43 |
|
| 44 |
|
| 45 |
def generate_html() -> str:
|
|
|
|
| 46 |
with open(DATA_FILE) as csvfile:
|
| 47 |
reader = csv.DictReader(csvfile)
|
| 48 |
rows = []
|
|
@@ -63,6 +64,7 @@ def generate_html() -> str:
|
|
| 63 |
|
| 64 |
|
| 65 |
def store_message(name: str, message: str):
|
|
|
|
| 66 |
if name and message:
|
| 67 |
with open(DATA_FILE, "a") as csvfile:
|
| 68 |
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
|
@@ -73,20 +75,12 @@ def store_message(name: str, message: str):
|
|
| 73 |
return generate_html()
|
| 74 |
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
css="""
|
| 84 |
-
.name {background-color:cornflowerblue;color:white; padding:4px;margin:4px;border-radius:4px; }
|
| 85 |
-
""",
|
| 86 |
-
title="Reading/writing to a HuggingFace dataset repo from Spaces",
|
| 87 |
-
description=f"This is a demo of how to do simple *shared data persistence* in a Gradio Space, backed by a dataset repo.",
|
| 88 |
-
article=f"The dataset repo is [{DATASET_REPO_URL}]({DATASET_REPO_URL})",
|
| 89 |
-
allow_flagging="never"
|
| 90 |
-
)
|
| 91 |
|
| 92 |
-
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
def generate_html() -> str:
|
| 46 |
+
"""Generate HTML content for the chat."""
|
| 47 |
with open(DATA_FILE) as csvfile:
|
| 48 |
reader = csv.DictReader(csvfile)
|
| 49 |
rows = []
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
def store_message(name: str, message: str):
|
| 67 |
+
"""Store the message and regenerate HTML content."""
|
| 68 |
if name and message:
|
| 69 |
with open(DATA_FILE, "a") as csvfile:
|
| 70 |
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
|
|
|
| 75 |
return generate_html()
|
| 76 |
|
| 77 |
|
| 78 |
+
with gr.Blocks() as feedback_page:
|
| 79 |
+
gr.Markdown(f"Live Dataset: [{DATASET_REPO_URL}]({DATASET_REPO_URL})")
|
| 80 |
+
name_input = components.Textbox(label="Your Username")
|
| 81 |
+
message_input = components.Textbox(label="Your Feedback", lines=2)
|
| 82 |
+
output_html = gr.HTML()
|
| 83 |
+
submit_button = gr.Button("Submit")
|
| 84 |
+
submit_button.click(store_message, inputs=[name_input, message_input], outputs=output_html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
feedback_page.launch()
|