awacke1 commited on
Commit
0da9a24
1 Parent(s): 00aee94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -2
app.py CHANGED
@@ -168,7 +168,7 @@ def get_wiki_summaryDF(search):
168
  return df
169
 
170
 
171
- def save_message(name, message):
172
  now = datetime.datetime.now()
173
  timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
174
  with open("chat.txt", "a") as f:
@@ -192,7 +192,7 @@ So, what are you waiting for? Join the fun and start chatting with Wikipedia and
192
  StreamlitWikipediaChat - where learning meets fun! 🤓🎈""")
193
 
194
 
195
- def main():
196
  st.title("Streamlit Chat")
197
 
198
  name = st.text_input("Enter your name")
@@ -234,6 +234,52 @@ def main():
234
 
235
  t = 60
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  if __name__ == "__main__":
238
  main()
239
 
 
168
  return df
169
 
170
 
171
+ def save_message_old1(name, message):
172
  now = datetime.datetime.now()
173
  timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
174
  with open("chat.txt", "a") as f:
 
192
  StreamlitWikipediaChat - where learning meets fun! 🤓🎈""")
193
 
194
 
195
+ def main_old1():
196
  st.title("Streamlit Chat")
197
 
198
  name = st.text_input("Enter your name")
 
234
 
235
  t = 60
236
 
237
+ def save_message(name, message):
238
+ with open("chat.txt", "a") as f:
239
+ f.write(f"{name}: {message}\n")
240
+
241
+ def main():
242
+ st.title("Streamlit Chat")
243
+
244
+ name = st.text_input("Enter your name")
245
+ message = st.text_input("Enter a topic to share from Wikipedia")
246
+ if st.button("Submit"):
247
+
248
+ # wiki
249
+ df = get_wiki_summaryDF(message)
250
+
251
+ save_message(name, message)
252
+ save_message(name, df)
253
+
254
+ st.text("Message sent!")
255
+
256
+ st.text("Chat history:")
257
+ with open("chat.txt", "a+") as f:
258
+ f.seek(0)
259
+ chat_history = f.read()
260
+ st.markdown(chat_history)
261
+
262
+ countdown = st.empty()
263
+ t = 60
264
+ while t:
265
+ mins, secs = divmod(t, 60)
266
+ countdown.text(f"Time remaining: {mins:02d}:{secs:02d}")
267
+ time.sleep(1)
268
+ t -= 1
269
+ if t == 0:
270
+ countdown.text("Time's up!")
271
+ with open("chat.txt", "a+") as f:
272
+ f.seek(0)
273
+ chat_history = f.read()
274
+ st.markdown(chat_history)
275
+
276
+ press_release()
277
+
278
+ t = 60
279
+
280
+
281
+
282
+
283
  if __name__ == "__main__":
284
  main()
285