add oauth
Browse files
app.py
CHANGED
|
@@ -3,13 +3,13 @@ from datasets import load_dataset, Dataset, concatenate_datasets
|
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
| 5 |
from huggingface_hub import hf_hub_download, whoami
|
| 6 |
-
from huggingface_hub import HfApi, ModelCard, whoami
|
| 7 |
|
| 8 |
# Load your private Hugging Face dataset
|
| 9 |
DATASET_NAME = "andito/technical_interview_internship_2025"
|
| 10 |
TOKEN = os.environ.get("HF_TOKEN")
|
| 11 |
EXERCISE_URL = os.environ.get("EXERCISE")
|
| 12 |
dataset = load_dataset(DATASET_NAME, split="train")
|
|
|
|
| 13 |
|
| 14 |
# Function to fetch the exercise file if not already downloaded
|
| 15 |
def fetch_exercise_file():
|
|
@@ -21,6 +21,8 @@ def log_to_hf_dataset(oauth_token: gr.OAuthToken | None):
|
|
| 21 |
return "You have to be logged in.", "README.md"
|
| 22 |
|
| 23 |
username = whoami(token=oauth_token.token)["name"]
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Get current timestamp
|
| 26 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
| 5 |
from huggingface_hub import hf_hub_download, whoami
|
|
|
|
| 6 |
|
| 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 |
+
whitelist = os.environ.get("WHITELIST").split(",")
|
| 13 |
|
| 14 |
# Function to fetch the exercise file if not already downloaded
|
| 15 |
def fetch_exercise_file():
|
|
|
|
| 21 |
return "You have to be logged in.", "README.md"
|
| 22 |
|
| 23 |
username = whoami(token=oauth_token.token)["name"]
|
| 24 |
+
if username not in whitelist:
|
| 25 |
+
return "You are not authorized to download the exercise.", "README.md"
|
| 26 |
|
| 27 |
# Get current timestamp
|
| 28 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|