awacke1 commited on
Commit
10c450b
·
1 Parent(s): 9a9269a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -16,7 +16,6 @@ DATASET_REPO_ID = "awacke1/Carddata.csv"
16
  DATA_FILENAME = "Carddata.csv"
17
  DATA_FILE = os.path.join("data", DATA_FILENAME)
18
  HF_TOKEN = os.environ.get("HF_TOKEN")
19
-
20
  SCRIPT = """
21
  <script>
22
  if (!window.hasBeenRun) {
@@ -26,7 +25,6 @@ if (!window.hasBeenRun) {
26
  }
27
  </script>
28
  """
29
-
30
  try:
31
  hf_hub_download(
32
  repo_id=DATASET_REPO_ID,
@@ -39,7 +37,6 @@ except:
39
  repo = Repository(
40
  local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
41
  )
42
-
43
  def generate_html() -> str:
44
  with open(DATA_FILE) as csvfile:
45
  reader = csv.DictReader(csvfile)
@@ -59,6 +56,7 @@ def generate_html() -> str:
59
  html += "</div>"
60
  return html
61
 
 
62
  def store_message(name: str, message: str):
63
  if name and message:
64
  with open(DATA_FILE, "a") as csvfile:
@@ -66,7 +64,8 @@ def store_message(name: str, message: str):
66
  writer.writerow(
67
  {"name": name.strip(), "message": message.strip(), "time": str(datetime.now())}
68
  )
69
- commit_url = repo.push_to_hub()
 
70
  return ""
71
 
72
  iface = gr.Interface(
 
16
  DATA_FILENAME = "Carddata.csv"
17
  DATA_FILE = os.path.join("data", DATA_FILENAME)
18
  HF_TOKEN = os.environ.get("HF_TOKEN")
 
19
  SCRIPT = """
20
  <script>
21
  if (!window.hasBeenRun) {
 
25
  }
26
  </script>
27
  """
 
28
  try:
29
  hf_hub_download(
30
  repo_id=DATASET_REPO_ID,
 
37
  repo = Repository(
38
  local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
39
  )
 
40
  def generate_html() -> str:
41
  with open(DATA_FILE) as csvfile:
42
  reader = csv.DictReader(csvfile)
 
56
  html += "</div>"
57
  return html
58
 
59
+
60
  def store_message(name: str, message: str):
61
  if name and message:
62
  with open(DATA_FILE, "a") as csvfile:
 
64
  writer.writerow(
65
  {"name": name.strip(), "message": message.strip(), "time": str(datetime.now())}
66
  )
67
+ # uncomment line below to begin saving. If creating your own copy you will need to add a access token called "HF_TOKEN" to your profile, then create a secret for your repo with the access code naming it "HF_TOKEN" For the CSV as well you can copy the header and first few lines to your own then update the paths above which should work to save to your own repository for datasets.
68
+ #commit_url = repo.push_to_hub()
69
  return ""
70
 
71
  iface = gr.Interface(