Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
from fpdf import FPDF
|
5 |
from datetime import datetime
|
|
|
6 |
|
7 |
# Initialize an empty DataFrame to store all invoice records
|
8 |
invoice_data = pd.DataFrame(columns=["Company Name", "Name", "Invoice No", "Date", "Amount"])
|
@@ -30,7 +30,6 @@ def add_invoice(company_name, name, invoice_no, date, amount):
|
|
30 |
# Function to generate and save the filtered invoice data to a PDF
|
31 |
def generate_pdf(company_name):
|
32 |
global invoice_data
|
33 |
-
|
34 |
try:
|
35 |
pdf = FPDF()
|
36 |
pdf.add_page()
|
@@ -71,7 +70,13 @@ def generate_pdf(company_name):
|
|
71 |
# Save PDF to file
|
72 |
pdf_file_path = "/content/invoice_records.pdf"
|
73 |
pdf.output(pdf_file_path)
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
return pdf_file_path
|
76 |
|
77 |
except Exception as e:
|
@@ -105,4 +110,3 @@ with gr.Blocks() as app:
|
|
105 |
|
106 |
# Launch the app
|
107 |
app.launch(share=True)
|
108 |
-
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from fpdf import FPDF
|
4 |
from datetime import datetime
|
5 |
+
import os # To check file existence
|
6 |
|
7 |
# Initialize an empty DataFrame to store all invoice records
|
8 |
invoice_data = pd.DataFrame(columns=["Company Name", "Name", "Invoice No", "Date", "Amount"])
|
|
|
30 |
# Function to generate and save the filtered invoice data to a PDF
|
31 |
def generate_pdf(company_name):
|
32 |
global invoice_data
|
|
|
33 |
try:
|
34 |
pdf = FPDF()
|
35 |
pdf.add_page()
|
|
|
70 |
# Save PDF to file
|
71 |
pdf_file_path = "/content/invoice_records.pdf"
|
72 |
pdf.output(pdf_file_path)
|
73 |
+
|
74 |
+
# Check if file exists
|
75 |
+
if os.path.exists(pdf_file_path):
|
76 |
+
print("PDF generated successfully.")
|
77 |
+
else:
|
78 |
+
print("Error: PDF not generated.")
|
79 |
+
|
80 |
return pdf_file_path
|
81 |
|
82 |
except Exception as e:
|
|
|
110 |
|
111 |
# Launch the app
|
112 |
app.launch(share=True)
|
|