andito HF staff commited on
Commit
48d708b
·
1 Parent(s): 3e0daf1

added file download

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -7,7 +7,16 @@ import os
7
  # Load your private Hugging Face dataset
8
  DATASET_NAME = "andito/technical_interview_internship_2025"
9
  TOKEN = os.environ.get("HF_TOKEN")
 
10
  dataset = load_dataset(DATASET_NAME, split="train")
 
 
 
 
 
 
 
 
11
 
12
  # Function to log download data to the HF Dataset
13
  def log_to_hf_dataset(username):
@@ -27,14 +36,14 @@ def log_to_hf_dataset(username):
27
  updated_dataset.push_to_hub(DATASET_NAME, token=TOKEN)
28
 
29
  # Provide file for download
30
- return "Thank you! Your download is ready.", "exercise.pdf" # Replace with your file path
31
 
32
  # Gradio interface
33
  with gr.Blocks() as demo:
34
  username = gr.Textbox(label="Enter your username", placeholder="Your Hugging Face username")
35
  download_button = gr.Button("Download Exercise")
36
  output = gr.Text()
37
- file = gr.File()
38
 
39
  download_button.click(log_to_hf_dataset, inputs=[username], outputs=[output, file])
40
 
 
7
  # Load your private Hugging Face dataset
8
  DATASET_NAME = "andito/technical_interview_internship_2025"
9
  TOKEN = os.environ.get("HF_TOKEN")
10
+ EXERCISE_URL = os.environ.get("EXERCISE")
11
  dataset = load_dataset(DATASET_NAME, split="train")
12
+ LOCAL_FILE_PATH = "exercise.pdf"
13
+
14
+ # Function to fetch the exercise file if not already downloaded
15
+ def fetch_exercise_file():
16
+ if not os.path.exists(LOCAL_FILE_PATH):
17
+ response = requests.get(EXERCISE_URL)
18
+ with open(LOCAL_FILE_PATH, "wb") as f:
19
+ f.write(response.content)
20
 
21
  # Function to log download data to the HF Dataset
22
  def log_to_hf_dataset(username):
 
36
  updated_dataset.push_to_hub(DATASET_NAME, token=TOKEN)
37
 
38
  # Provide file for download
39
+ return "Thank you! Your download is ready.", LOCAL_FILE_PATH # Replace with your file path
40
 
41
  # Gradio interface
42
  with gr.Blocks() as demo:
43
  username = gr.Textbox(label="Enter your username", placeholder="Your Hugging Face username")
44
  download_button = gr.Button("Download Exercise")
45
  output = gr.Text()
46
+ file = gr.File(label="Download your exercise file")
47
 
48
  download_button.click(log_to_hf_dataset, inputs=[username], outputs=[output, file])
49