Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,10 @@
|
|
1 |
-
# Step 1:
|
2 |
-
# !pip install gradio fpdf pandas
|
3 |
-
|
4 |
-
# Step 2: Import necessary libraries
|
5 |
import gradio as gr
|
6 |
from fpdf import FPDF
|
7 |
import pandas as pd
|
8 |
import os
|
9 |
|
10 |
-
# Step
|
11 |
def submit_form(name, whatsapp, membership, protest):
|
12 |
# Save form data to a CSV file (backend storage)
|
13 |
data = {'Name': [name], 'WhatsApp': [whatsapp], 'Membership': [membership], 'Protest': [protest]}
|
@@ -39,24 +36,13 @@ def submit_form(name, whatsapp, membership, protest):
|
|
39 |
pdf_output_path = "/tmp/form_data.pdf"
|
40 |
pdf.output(pdf_output_path)
|
41 |
|
42 |
-
# Return
|
43 |
-
return
|
44 |
|
45 |
-
# Step
|
46 |
with gr.Blocks() as demo:
|
47 |
gr.Markdown("## Submit Your Information")
|
48 |
|
49 |
-
# Agenda of YEP
|
50 |
-
gr.Markdown("""
|
51 |
-
### Young Engineers Pakistan (YEP) Agenda
|
52 |
-
1. Grant rights to Young Engineers in the Governing Body.
|
53 |
-
2. Provide detailed transparency of PEC expenses, showing how thousands of rupees are utilized by PEC employees.
|
54 |
-
3. Immediately withdraw all illegal notifications and promotions.
|
55 |
-
4. Grant Young Engineers the right to resign from and rejoin any company.
|
56 |
-
5. Provide Young Engineers with opportunities for internships, innovation, and access to an Incubation Center.
|
57 |
-
6. The new PEC building should be used as an Incubation Center, not for renting purposes.
|
58 |
-
""")
|
59 |
-
|
60 |
# Form input fields
|
61 |
name = gr.Textbox(label="Name", placeholder="Enter your name here")
|
62 |
whatsapp = gr.Textbox(label="WhatsApp Mobile No.", placeholder="Enter your WhatsApp mobile number here")
|
@@ -65,12 +51,13 @@ with gr.Blocks() as demo:
|
|
65 |
|
66 |
submit = gr.Button("Submit")
|
67 |
|
68 |
-
#
|
69 |
-
|
70 |
|
71 |
-
# Link the button to the function
|
72 |
-
submit.click(
|
73 |
|
74 |
-
# Step
|
75 |
demo.launch()
|
76 |
|
|
|
|
1 |
+
# Step 1: Import necessary libraries
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from fpdf import FPDF
|
4 |
import pandas as pd
|
5 |
import os
|
6 |
|
7 |
+
# Step 2: Define a function to handle form submission and generate a PDF file
|
8 |
def submit_form(name, whatsapp, membership, protest):
|
9 |
# Save form data to a CSV file (backend storage)
|
10 |
data = {'Name': [name], 'WhatsApp': [whatsapp], 'Membership': [membership], 'Protest': [protest]}
|
|
|
36 |
pdf_output_path = "/tmp/form_data.pdf"
|
37 |
pdf.output(pdf_output_path)
|
38 |
|
39 |
+
# Return the path to the generated PDF for download
|
40 |
+
return pdf_output_path
|
41 |
|
42 |
+
# Step 3: Set up the Gradio interface with the form and PDF download link
|
43 |
with gr.Blocks() as demo:
|
44 |
gr.Markdown("## Submit Your Information")
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Form input fields
|
47 |
name = gr.Textbox(label="Name", placeholder="Enter your name here")
|
48 |
whatsapp = gr.Textbox(label="WhatsApp Mobile No.", placeholder="Enter your WhatsApp mobile number here")
|
|
|
51 |
|
52 |
submit = gr.Button("Submit")
|
53 |
|
54 |
+
# Display a message and PDF download link after form submission
|
55 |
+
pdf_output = gr.File(label="Download your PDF")
|
56 |
|
57 |
+
# Link the button to the function
|
58 |
+
submit.click(submit_form, inputs=[name, whatsapp, membership, protest], outputs=pdf_output)
|
59 |
|
60 |
+
# Step 4: Launch the Gradio app
|
61 |
demo.launch()
|
62 |
|
63 |
+
|