sjw commited on
Commit
665240f
·
1 Parent(s): c543299

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -56
app.py CHANGED
@@ -12,16 +12,6 @@ DIRNAME = "data"
12
  DATA_FILE = os.path.join(DIRNAME, DATA_FILENAME)
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
14
 
15
- # # overriding/appending to the gradio template
16
- # SCRIPT = """
17
- # <script>
18
- # if (!window.hasBeenRun) {
19
- # window.hasBeenRun = true;
20
- # console.log("should only happen once");
21
- # document.querySelector("button.submit").click();
22
- # }
23
- # </script>
24
- # """
25
 
26
  try:
27
  hf_hub_download(
@@ -36,52 +26,7 @@ repo = Repository(
36
  local_dir = DIRNAME, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
37
  )
38
 
39
- # def generate_html() -> str:
40
- # with open(DATA_FILE) as csvfile:
41
- # reader = csv.DictReader(csvfile)
42
- # rows = []
43
- # for row in reader:
44
- # rows.append(row)
45
- # rows.reverse()
46
- # if len(rows) == 0:
47
- # return "no messages yet"
48
- # else:
49
- # html = "<div class='chatbot'>"
50
- # for row in rows:
51
- # html += "<div>"
52
- # html += f"<span>{row['name']}</span>"
53
- # html += f"<span class='message'>{row['message']}</span>"
54
- # html += "</div>"
55
- # html += "</div>"
56
- # return html
57
 
58
- # def store_message(name: str, message: str):
59
- # if name and message:
60
- # with open(DATA_FILE, "a") as csvfile:
61
- # writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
62
- # writer.writerow(
63
- # {"name": name, "message": message, "time": str(datetime.now())}
64
- # )
65
- # commit_url = repo.push_to_hub()
66
- # return generate_html()
67
-
68
- # iface = gr.Interface(
69
- # store_message,
70
- # [
71
- # components.Textbox(placeholder="Your name"),
72
- # components.Textbox(placeholder="Your message", lines=2),
73
- # ],
74
- # "html",
75
- # css="""
76
- # .name {background-color:cornflowerblue;color:white; padding:4px;margin:4px;border-radius:4px; }
77
- # """,
78
- # title="Reading/writing to a HuggingFace dataset repo from Spaces",
79
- # description=f"This is a demo of how to do simple *shared data persistence* in a Gradio Space, backed by a dataset repo.",
80
- # article=f"The dataset repo is [{DATASET_REPO_URL}]({DATASET_REPO_URL})",
81
- # allow_flagging="never"
82
- # )
83
-
84
- # iface.launch()
85
  def generate_html() -> str:
86
  with open(DATA_FILE) as csvfile:
87
  reader = csv.DictReader(csvfile)
@@ -109,7 +54,7 @@ def store_message(name: str, message: str):
109
  writer.writerow(
110
  {"name": name, "message": message, "time": str(datetime.now())}
111
  )
112
- commit_url = repo.push_to_hub()
113
  return generate_html()
114
 
115
  with gr.Blocks() as demo:
 
12
  DATA_FILE = os.path.join(DIRNAME, DATA_FILENAME)
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
14
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  try:
17
  hf_hub_download(
 
26
  local_dir = DIRNAME, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
27
  )
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def generate_html() -> str:
31
  with open(DATA_FILE) as csvfile:
32
  reader = csv.DictReader(csvfile)
 
54
  writer.writerow(
55
  {"name": name, "message": message, "time": str(datetime.now())}
56
  )
57
+ #commit_url = repo.push_to_hub()
58
  return generate_html()
59
 
60
  with gr.Blocks() as demo: