import gradio as gr | |
def create_simple_pdf_viewer(): | |
""" | |
Creates a simple Gradio app with just a button to view a PDF. | |
""" | |
with gr.Blocks() as app: | |
gr.Markdown("# Simple PDF Viewer") | |
# Create a button to trigger showing the PDF | |
view_button = gr.Button("View Hate Speech Policy") | |
# Create a file component that will display the PDF | |
pdf_viewer = gr.File( | |
value="Hate Speech Policy.pdf", # Path to your PDF file | |
label="Hate Speech Policy Document", | |
interactive=False, | |
visible=False # Initially hidden | |
) | |
# Define a simple function to show the PDF | |
def show_pdf(): | |
return gr.update(visible=True) | |
# Connect the button to the function | |
view_button.click( | |
fn=show_pdf, | |
inputs=None, | |
outputs=pdf_viewer, | |
queue=False # No need for queue | |
) | |
return app | |
# Main function | |
if __name__ == "__main__": | |
app = create_simple_pdf_viewer() | |
app.launch() |