File size: 824 Bytes
a107121 1701a52 a107121 1701a52 a107121 4d67a1a a107121 bf363fd a107121 18c88a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import gradio as gr
from datetime import datetime
from utils import gen_html, convert_html_to_pdf
import os
def generate_pdf(num_questions):
now = datetime.now()
filename = now.strftime("%Y_%m_%d_AMC.pdf")
allhtml = gen_html(num_questions)
convert_html_to_pdf(allhtml, filename)
return filename
def lucky_button(num_questions):
pdf_file = generate_pdf(num_questions)
return pdf_file
interface = gr.Interface(
fn=lucky_button,
inputs=gr.Slider(minimum=1, maximum=20, step=1, value=5, label="Number of Questions"),
outputs=gr.File(label="Generated PDF"),
title="Random AMC/AIME Problem PDF Generator",
description="Click the button to generate a random HTML of AMC/AIME problems. You can specify the number of questions to include in the PDF."
)
interface.launch()
|