Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,11 +19,15 @@ from gradio import inputs, outputs
|
|
| 19 |
import huggingface_hub
|
| 20 |
from huggingface_hub import Repository, hf_hub_download, upload_file
|
| 21 |
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
| 22 |
DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/Carddata.csv"
|
| 23 |
DATASET_REPO_ID = "awacke1/Carddata.csv"
|
| 24 |
DATA_FILENAME = "Carddata.csv"
|
| 25 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 26 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
|
| 27 |
|
| 28 |
SCRIPT = """
|
| 29 |
<script>
|
|
@@ -34,8 +38,6 @@ if (!window.hasBeenRun) {
|
|
| 34 |
}
|
| 35 |
</script>
|
| 36 |
"""
|
| 37 |
-
|
| 38 |
-
|
| 39 |
try:
|
| 40 |
hf_hub_download(
|
| 41 |
repo_id=DATASET_REPO_ID,
|
|
@@ -48,7 +50,6 @@ except:
|
|
| 48 |
repo = Repository(
|
| 49 |
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
| 50 |
)
|
| 51 |
-
|
| 52 |
def generate_html() -> str:
|
| 53 |
with open(DATA_FILE) as csvfile:
|
| 54 |
reader = csv.DictReader(csvfile)
|
|
@@ -76,7 +77,8 @@ def store_message(name: str, message: str):
|
|
| 76 |
writer.writerow(
|
| 77 |
{"name": name.strip(), "message": message.strip(), "time": str(datetime.now())}
|
| 78 |
)
|
| 79 |
-
|
|
|
|
| 80 |
return ""
|
| 81 |
|
| 82 |
|
|
|
|
| 19 |
import huggingface_hub
|
| 20 |
from huggingface_hub import Repository, hf_hub_download, upload_file
|
| 21 |
from datetime import datetime
|
| 22 |
+
|
| 23 |
+
# Dataset and Token links - change awacke1 to your own HF id, and add a HF_TOKEN copy to your repo for write permissions
|
| 24 |
+
# This should allow you to save your results to your own Dataset hosted on HF. ---
|
| 25 |
DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/Carddata.csv"
|
| 26 |
DATASET_REPO_ID = "awacke1/Carddata.csv"
|
| 27 |
DATA_FILENAME = "Carddata.csv"
|
| 28 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 29 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 30 |
+
# ---------------------------------------------
|
| 31 |
|
| 32 |
SCRIPT = """
|
| 33 |
<script>
|
|
|
|
| 38 |
}
|
| 39 |
</script>
|
| 40 |
"""
|
|
|
|
|
|
|
| 41 |
try:
|
| 42 |
hf_hub_download(
|
| 43 |
repo_id=DATASET_REPO_ID,
|
|
|
|
| 50 |
repo = Repository(
|
| 51 |
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
| 52 |
)
|
|
|
|
| 53 |
def generate_html() -> str:
|
| 54 |
with open(DATA_FILE) as csvfile:
|
| 55 |
reader = csv.DictReader(csvfile)
|
|
|
|
| 77 |
writer.writerow(
|
| 78 |
{"name": name.strip(), "message": message.strip(), "time": str(datetime.now())}
|
| 79 |
)
|
| 80 |
+
# uncomment line below to begin saving -
|
| 81 |
+
#commit_url = repo.push_to_hub()
|
| 82 |
return ""
|
| 83 |
|
| 84 |
|