Seetha commited on
Commit
3c9c1fb
·
1 Parent(s): 1b9fe96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -32
app.py CHANGED
@@ -542,18 +542,18 @@ def main():
542
  #data = json.load(fi)
543
  fi.write(json_data)
544
 
545
- # overriding/appending to the gradio template
546
- SCRIPT = """
547
- <script>
548
- if (!window.hasBeenRun) {
549
- window.hasBeenRun = true;
550
- console.log("should only happen once");
551
- document.querySelector("button.submit").click();
552
- }
553
- </script>
554
- """
555
- with open(os.path.join(gr.networking.STATIC_TEMPLATE_LIB, "frontend", "index.html"), "a") as f:
556
- f.write(SCRIPT)
557
 
558
  try:
559
  hf_hub_download(
@@ -566,34 +566,34 @@ def main():
566
  st.write("file not found")
567
 
568
  repo = Repository(
569
- local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
570
  )
571
 
572
- def generate_html() -> str:
573
- with open(DATA_FILE) as csvfile:
574
- reader = json.dumps(json_data)
575
- rows = []
576
- for row in reader:
577
- rows.append(row)
578
- rows.reverse()
579
- if len(rows) == 0:
580
- return "no messages yet"
581
- else:
582
- html = "<div class='chatbot'>"
583
- for row in rows:
584
- html += "<div>"
585
- html += f"<span>{row['name']}</span>"
586
- html += f"<span class='message'>{row['message']}</span>"
587
- html += "</div>"
588
- html += "</div>"
589
- return html
590
 
591
  def store_message():
592
  if name and message:
593
  with open(DATA_FILE, "a") as csvfile:
594
  writer = json.dumps(json_data)
595
  commit_url = repo.push_to_hub()
596
- return generate_html()
597
 
598
  iface = gr.Interface(
599
  store_message,
 
542
  #data = json.load(fi)
543
  fi.write(json_data)
544
 
545
+ # # overriding/appending to the gradio template
546
+ # SCRIPT = """
547
+ # <script>
548
+ # if (!window.hasBeenRun) {
549
+ # window.hasBeenRun = true;
550
+ # console.log("should only happen once");
551
+ # document.querySelector("button.submit").click();
552
+ # }
553
+ # </script>
554
+ # """
555
+ # with open(os.path.join(gr.networking.STATIC_TEMPLATE_LIB, "frontend", "index.html"), "a") as f:
556
+ # f.write(SCRIPT)
557
 
558
  try:
559
  hf_hub_download(
 
566
  st.write("file not found")
567
 
568
  repo = Repository(
569
+ local_dir="level2", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
570
  )
571
 
572
+ # def generate_html() -> str:
573
+ # with open(DATA_FILE) as csvfile:
574
+ # reader = json.dumps(json_data)
575
+ # rows = []
576
+ # for row in reader:
577
+ # rows.append(row)
578
+ # rows.reverse()
579
+ # if len(rows) == 0:
580
+ # return "no messages yet"
581
+ # else:
582
+ # html = "<div class='chatbot'>"
583
+ # for row in rows:
584
+ # html += "<div>"
585
+ # html += f"<span>{row['name']}</span>"
586
+ # html += f"<span class='message'>{row['message']}</span>"
587
+ # html += "</div>"
588
+ # html += "</div>"
589
+ # return html
590
 
591
  def store_message():
592
  if name and message:
593
  with open(DATA_FILE, "a") as csvfile:
594
  writer = json.dumps(json_data)
595
  commit_url = repo.push_to_hub()
596
+ # return generate_html()
597
 
598
  iface = gr.Interface(
599
  store_message,