ymcmy's picture
Update app.py
bf363fd verified
raw
history blame
824 Bytes
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()