ymcmy's picture
Update app.py
4d67a1a verified
raw
history blame
832 Bytes
import gradio as gr
from weasyprint import HTML
from datetime import datetime
from utils import gen_html
import os
def generate_pdf(num_questions):
now = datetime.now()
filename = now.strftime("%Y_%m_%d_AMC.pdf")
allhtml = gen_html(num_questions)
HTML(string=allhtml).write_pdf(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 PDF of AMC/AIME problems. You can specify the number of questions to include in the PDF."
)
interface.launch()