File size: 1,094 Bytes
72058bd |
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 29 30 31 32 33 34 35 36 37 38 |
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() |