atifsial123 commited on
Commit
d6b0bbd
·
verified ·
1 Parent(s): 667b489

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # Step 1: Install Gradio and FPDF (For Hugging Face Spaces, use requirements.txt)
2
  # !pip install gradio fpdf pandas
3
 
4
  # Step 2: Import necessary libraries
@@ -39,10 +39,10 @@ def submit_form(name, whatsapp, membership, protest):
39
  pdf_output_path = "/tmp/form_data.pdf"
40
  pdf.output(pdf_output_path)
41
 
42
- # Return a success message instead of the PDF file for the user
43
- return "Thank you for your submission!"
44
 
45
- # Step 4: Set up the Gradio interface to ensure the message is displayed properly
46
  with gr.Blocks() as demo:
47
  gr.Markdown("## Submit Your Information")
48
 
@@ -65,11 +65,12 @@ with gr.Blocks() as demo:
65
 
66
  submit = gr.Button("Submit")
67
 
68
- # Output message box for submission confirmation
69
  output_message = gr.Textbox(label="Output Message", visible=True)
70
 
71
- # Link the button to the function, and display the success message
72
- submit.click(fn=submit_form, inputs=[name, whatsapp, membership, protest], outputs=output_message)
73
 
74
  # Step 5: Launch the Gradio app
75
  demo.launch()
 
 
1
+ # Step 1: Install Gradio and FPDF (Hugging Face Spaces will use requirements.txt)
2
  # !pip install gradio fpdf pandas
3
 
4
  # Step 2: Import necessary libraries
 
39
  pdf_output_path = "/tmp/form_data.pdf"
40
  pdf.output(pdf_output_path)
41
 
42
+ # Return a success message and the PDF download link for the admin
43
+ return f"Thank you for your submission! [Download PDF](form_data.pdf)", pdf_output_path
44
 
45
+ # Step 4: Set up the Gradio interface
46
  with gr.Blocks() as demo:
47
  gr.Markdown("## Submit Your Information")
48
 
 
65
 
66
  submit = gr.Button("Submit")
67
 
68
+ # Output message box for submission confirmation and PDF download link
69
  output_message = gr.Textbox(label="Output Message", visible=True)
70
 
71
+ # Link the button to the function, and display the success message with download link
72
+ submit.click(fn=submit_form, inputs=[name, whatsapp, membership, protest], outputs=[output_message, gr.File()])
73
 
74
  # Step 5: Launch the Gradio app
75
  demo.launch()
76
+