Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,25 +54,24 @@ def generate_html() -> str:
|
|
| 54 |
rows.append(row)
|
| 55 |
rows.reverse()
|
| 56 |
if len(rows) == 0:
|
| 57 |
-
return "
|
| 58 |
else:
|
| 59 |
html = "<div class='chatbot'>"
|
| 60 |
for row in rows:
|
| 61 |
html += "<div>"
|
| 62 |
html += f"<span>{row['name']}</span>"
|
| 63 |
-
html += f"<span>{row['
|
| 64 |
-
html += f"<span class='celsci'>{row['celsci']}</span>"
|
| 65 |
html += "</div>"
|
| 66 |
html += "</div>"
|
| 67 |
return html
|
| 68 |
|
| 69 |
|
| 70 |
-
def store_message(name: str,
|
| 71 |
if name and message:
|
| 72 |
with open(DATA_FILE, "a") as csvfile:
|
| 73 |
-
writer = csv.DictWriter(csvfile, fieldnames=["name", "
|
| 74 |
writer.writerow(
|
| 75 |
-
{"name": name, "
|
| 76 |
)
|
| 77 |
commit_url = upload_file(
|
| 78 |
DATA_FILE,
|
|
@@ -90,8 +89,7 @@ iface = gr.Interface(
|
|
| 90 |
store_message,
|
| 91 |
[
|
| 92 |
inputs.Textbox(placeholder="Your name"),
|
| 93 |
-
inputs.Textbox(placeholder="
|
| 94 |
-
inputs.Textbox(placeholder="Celsci"), #, lines=2),
|
| 95 |
],
|
| 96 |
"html",
|
| 97 |
css="""
|
|
@@ -102,4 +100,4 @@ iface = gr.Interface(
|
|
| 102 |
article=f"The dataset repo is [{DATASET_REPO_URL}]({DATASET_REPO_URL})",
|
| 103 |
)
|
| 104 |
|
| 105 |
-
iface.launch()
|
|
|
|
| 54 |
rows.append(row)
|
| 55 |
rows.reverse()
|
| 56 |
if len(rows) == 0:
|
| 57 |
+
return "no messages yet"
|
| 58 |
else:
|
| 59 |
html = "<div class='chatbot'>"
|
| 60 |
for row in rows:
|
| 61 |
html += "<div>"
|
| 62 |
html += f"<span>{row['name']}</span>"
|
| 63 |
+
html += f"<span class='message'>{row['message']}</span>"
|
|
|
|
| 64 |
html += "</div>"
|
| 65 |
html += "</div>"
|
| 66 |
return html
|
| 67 |
|
| 68 |
|
| 69 |
+
def store_message(name: str, message: str):
|
| 70 |
if name and message:
|
| 71 |
with open(DATA_FILE, "a") as csvfile:
|
| 72 |
+
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
| 73 |
writer.writerow(
|
| 74 |
+
{"name": name, "message": message, "time": str(datetime.now())}
|
| 75 |
)
|
| 76 |
commit_url = upload_file(
|
| 77 |
DATA_FILE,
|
|
|
|
| 89 |
store_message,
|
| 90 |
[
|
| 91 |
inputs.Textbox(placeholder="Your name"),
|
| 92 |
+
inputs.Textbox(placeholder="Your message", lines=2),
|
|
|
|
| 93 |
],
|
| 94 |
"html",
|
| 95 |
css="""
|
|
|
|
| 100 |
article=f"The dataset repo is [{DATASET_REPO_URL}]({DATASET_REPO_URL})",
|
| 101 |
)
|
| 102 |
|
| 103 |
+
iface.launch()
|