gursul commited on
Commit
6beee17
·
verified ·
1 Parent(s): 1de696e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -12,6 +12,10 @@ DATASET_REPO = "gursul/german_exercise_dataset"
12
  ENGLISH_WORDS_FILE = "en_de.json"
13
  GERMAN_WORDS_FILE = "de_en.json"
14
 
 
 
 
 
15
  def ensure_json_file(path):
16
  if not os.path.exists(path):
17
  with open(path, "w", encoding="utf-8") as f:
@@ -38,7 +42,8 @@ def save_english(d: dict):
38
  path_or_fileobj=ENGLISH_WORDS_FILE,
39
  path_in_repo="en_de.json",
40
  repo_id=DATASET_REPO,
41
- repo_type="dataset"
 
42
  )
43
 
44
  def save_german(d: dict):
@@ -47,7 +52,8 @@ def save_german(d: dict):
47
  path_or_fileobj=GERMAN_WORDS_FILE,
48
  path_in_repo="de_en.json",
49
  repo_id=DATASET_REPO,
50
- repo_type="dataset"
 
51
  )
52
 
53
  def new_word():
 
12
  ENGLISH_WORDS_FILE = "en_de.json"
13
  GERMAN_WORDS_FILE = "de_en.json"
14
 
15
+ # Authenticate once at startup
16
+ if "HF_TOKEN" in os.environ:
17
+ login(token=os.environ["HF_TOKEN"])
18
+
19
  def ensure_json_file(path):
20
  if not os.path.exists(path):
21
  with open(path, "w", encoding="utf-8") as f:
 
42
  path_or_fileobj=ENGLISH_WORDS_FILE,
43
  path_in_repo="en_de.json",
44
  repo_id=DATASET_REPO,
45
+ repo_type="dataset",
46
+ token=os.environ.get("HF_TOKEN")
47
  )
48
 
49
  def save_german(d: dict):
 
52
  path_or_fileobj=GERMAN_WORDS_FILE,
53
  path_in_repo="de_en.json",
54
  repo_id=DATASET_REPO,
55
+ repo_type="dataset",
56
+ token=os.environ.get("HF_TOKEN")
57
  )
58
 
59
  def new_word():