Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import pdfkit
|
| 3 |
from datetime import datetime
|
| 4 |
-
from utils import gen_html
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
def
|
| 8 |
now = datetime.now()
|
| 9 |
-
filename = now.strftime("%Y_%m_%d_AMC.
|
| 10 |
-
|
| 11 |
-
allhtml = gen_html(num_questions)
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
return filename
|
| 16 |
|
| 17 |
def lucky_button(num_questions):
|
| 18 |
-
|
| 19 |
-
return
|
| 20 |
|
| 21 |
interface = gr.Interface(
|
| 22 |
fn=lucky_button,
|
| 23 |
inputs=gr.Slider(minimum=1, maximum=20, step=1, value=5, label="Number of Questions"),
|
| 24 |
-
outputs=gr.File(label="Generated
|
| 25 |
-
title="Random AMC/AIME Problem
|
| 26 |
-
description="Click the button to generate a random HTML of AMC/AIME problems. You can specify the number of questions to include in the
|
| 27 |
)
|
| 28 |
|
| 29 |
-
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from datetime import datetime
|
| 3 |
+
from utils import gen_html, save_html_to_file
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
def generate_html(num_questions):
|
| 7 |
now = datetime.now()
|
| 8 |
+
filename = now.strftime("%Y_%m_%d_AMC.html")
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
allhtml = gen_html(num_questions)
|
| 11 |
+
save_html_to_file(allhtml, filename)
|
| 12 |
|
| 13 |
return filename
|
| 14 |
|
| 15 |
def lucky_button(num_questions):
|
| 16 |
+
html_file = generate_html(num_questions)
|
| 17 |
+
return html_file
|
| 18 |
|
| 19 |
interface = gr.Interface(
|
| 20 |
fn=lucky_button,
|
| 21 |
inputs=gr.Slider(minimum=1, maximum=20, step=1, value=5, label="Number of Questions"),
|
| 22 |
+
outputs=gr.File(label="Generated HTML"),
|
| 23 |
+
title="Random AMC/AIME Problem HTML Generator",
|
| 24 |
+
description="Click the button to generate a random HTML file of AMC/AIME problems. You can specify the number of questions to include in the HTML."
|
| 25 |
)
|
| 26 |
|
| 27 |
+
interface.launch()
|