Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,33 @@ number_of_decks = 6
|
|
16 |
blackjack_multiplier = 1.5
|
17 |
|
18 |
def generate_html() -> str:
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def store_message(name: str, message: str):
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Initialize player, dealer, deck and game play. Cache these variables
|
25 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True)
|
|
|
16 |
blackjack_multiplier = 1.5
|
17 |
|
18 |
def generate_html() -> str:
|
19 |
+
with open(DATA_FILE) as csvfile:
|
20 |
+
reader = csv.DictReader(csvfile)
|
21 |
+
rows = []
|
22 |
+
for row in reader:
|
23 |
+
rows.append(row)
|
24 |
+
rows.reverse()
|
25 |
+
if len(rows) == 0:
|
26 |
+
return "no messages yet"
|
27 |
+
else:
|
28 |
+
html = "<div class='chatbot'>"
|
29 |
+
for row in rows:
|
30 |
+
html += "<div>"
|
31 |
+
html += f"<span>{row['name']}</span>"
|
32 |
+
html += f"<span class='message'>{row['message']}</span>"
|
33 |
+
html += "</div>"
|
34 |
+
html += "</div>"
|
35 |
+
return html
|
36 |
+
|
37 |
def store_message(name: str, message: str):
|
38 |
+
if name and message:
|
39 |
+
with open(DATA_FILE, "a") as csvfile:
|
40 |
+
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
41 |
+
writer.writerow(
|
42 |
+
{"name": name, "message": message, "time": str(datetime.now())}
|
43 |
+
)
|
44 |
+
commit_url = repo.push_to_hub()
|
45 |
+
return generate_html()
|
46 |
|
47 |
# Initialize player, dealer, deck and game play. Cache these variables
|
48 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True)
|