Mishmosh commited on
Commit
abe1234
·
1 Parent(s): 4fd0f5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -1,23 +1,24 @@
1
  import gradio as gr
2
 
3
- # Function to process the input message and PDF file
4
- def process_input(message, pdf_file):
5
- # Save the uploaded PDF file
6
- pdf_file.save("uploaded_pdf.pdf")
7
-
8
- # Process the message and return a result
9
- result = f"Message: {message}\nPDF file uploaded successfully!"
10
- return result
 
11
 
12
  # Gradio interface
13
  iface = gr.Interface(
14
- fn=process_input,
15
- inputs=[
16
- gr.inputs.Textbox(label="Enter your message"),
17
- gr.inputs.File(label="Upload a PDF file", type="file", accept=".pdf")
18
- ],
19
- outputs=gr.outputs.Textbox(label="Result")
20
  )
21
 
22
- # Launch the Gradio interface
23
  iface.launch()
 
1
  import gradio as gr
2
 
3
+ # Function to handle the uploaded PDF file
4
+ def handle_uploaded_pdf(pdf_file):
5
+ # Save the uploaded PDF file for later use
6
+ pdf_file_path = "uploaded_file.pdf"
7
+ pdf_file.save(pdf_file_path)
8
+
9
+ # Print a welcome message
10
+ welcome_message = "Welcome! PDF file uploaded successfully. You can use the uploaded file later."
11
+ print(welcome_message)
12
 
13
  # Gradio interface
14
  iface = gr.Interface(
15
+ fn=handle_uploaded_pdf,
16
+ inputs=gr.File(label="Upload PDF", type="file"),
17
+ outputs="text",
18
+ live=True,
19
+ title="Welcome and PDF Upload",
20
+ description="This interface prints a welcome message and allows you to upload a PDF file for later use."
21
  )
22
 
23
+ # Launch the interface
24
  iface.launch()