Manikandan-Alagu commited on
Commit
307e4e1
·
verified ·
1 Parent(s): 03745bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -72,21 +72,32 @@ with st.form("user_inputs"):
72
 
73
  def download(df):
74
  col1, col2 = st.columns(2)
75
- html_content=df.to_html(index=False)
76
- pdf_path= "generated_mcqs.pdf"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- if button:
79
- col1.download_button(label="Download CSV",
80
- data=df.to_csv(index=False).encode("utf-8"),
81
- file_name="generated_mcqs.csv",
82
- key="csv-download",
83
- help="Click to download as CSV"
84
- )
85
-
86
- col2.download_button(label="Download PDF",
87
- data= HTML(string=html_content).write_pdf(pdf_path),
88
- key="pdf-download",
89
- help="Click to download as PDF")
90
 
91
 
92
 
 
72
 
73
  def download(df):
74
  col1, col2 = st.columns(2)
75
+ html_content = df.to_html(index=False)
76
+ pdf_path = "generated_mcqs.pdf"
77
+
78
+ if button:
79
+ # Download CSV
80
+ col1.download_button(
81
+ label="Download CSV",
82
+ data=df.to_csv(index=False).encode("utf-8"),
83
+ file_name="generated_mcqs.csv",
84
+ key="csv-download",
85
+ help="Click to download as CSV",
86
+ )
87
+
88
+ # Download PDF
89
+ pdf_data = HTML(string=html_content).write_pdf(pdf_path)
90
+
91
+ if pdf_data is not None:
92
+ col2.download_button(
93
+ label="Download PDF",
94
+ data=pdf_data,
95
+ key="pdf-download",
96
+ help="Click to download as PDF",
97
+ )
98
+ else:
99
+ st.warning("PDF generation failed. Please try again.")
100
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
 
103