Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def has_certificate_entry(username):
|
|
27 |
return any(row["username"] == username for row in cert_data)
|
28 |
|
29 |
# Function to add certificate entry
|
30 |
-
def add_certificate_entry(username, name):
|
31 |
# Load current dataset
|
32 |
ds = load_dataset(CERTIFICATES_DATASET, split="train", download_mode="force_redownload")
|
33 |
|
@@ -37,7 +37,7 @@ def add_certificate_entry(username, name):
|
|
37 |
# Append the updated/new entry
|
38 |
new_entry = {
|
39 |
"username": username,
|
40 |
-
"
|
41 |
"timestamp": datetime.now().isoformat()
|
42 |
}
|
43 |
filtered_rows.append(new_entry)
|
@@ -85,7 +85,7 @@ def handle_certificate(name, profile: gr.OAuthProfile):
|
|
85 |
return f"Your score is {score}. You need at least {THRESHOLD_SCORE} to pass.", None, None
|
86 |
|
87 |
certificate_image, certificate_pdf = generate_certificate(name, score)
|
88 |
-
add_certificate_entry(username, name)
|
89 |
return "Congratulations! Here's your certificate:", certificate_image, certificate_pdf
|
90 |
|
91 |
# Gradio interface
|
|
|
27 |
return any(row["username"] == username for row in cert_data)
|
28 |
|
29 |
# Function to add certificate entry
|
30 |
+
def add_certificate_entry(username, name, score):
|
31 |
# Load current dataset
|
32 |
ds = load_dataset(CERTIFICATES_DATASET, split="train", download_mode="force_redownload")
|
33 |
|
|
|
37 |
# Append the updated/new entry
|
38 |
new_entry = {
|
39 |
"username": username,
|
40 |
+
"score": score,
|
41 |
"timestamp": datetime.now().isoformat()
|
42 |
}
|
43 |
filtered_rows.append(new_entry)
|
|
|
85 |
return f"Your score is {score}. You need at least {THRESHOLD_SCORE} to pass.", None, None
|
86 |
|
87 |
certificate_image, certificate_pdf = generate_certificate(name, score)
|
88 |
+
add_certificate_entry(username, name, score)
|
89 |
return "Congratulations! Here's your certificate:", certificate_image, certificate_pdf
|
90 |
|
91 |
# Gradio interface
|