Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -245,14 +245,23 @@ def getfromdropboxImg(jsdata):
|
|
| 245 |
def table():
|
| 246 |
# 1. Get PDF bytes from Dropbox
|
| 247 |
tt = eval(request.form.get('answers')) # consider json.loads instead of eval
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
# 2. Generate in-memory Excel
|
| 254 |
-
|
| 255 |
-
|
| 256 |
# 3. Send it as a downloadable .xlsx
|
| 257 |
if excel_io is None:
|
| 258 |
# No tables → return a JSON error (or another response of your choice)
|
|
|
|
| 245 |
def table():
|
| 246 |
# 1. Get PDF bytes from Dropbox
|
| 247 |
tt = eval(request.form.get('answers')) # consider json.loads instead of eval
|
| 248 |
+
print("Value of tt = ",tt)
|
| 249 |
+
print("Value of tt[0] = ",tt[0])
|
| 250 |
+
pdflist=[]
|
| 251 |
+
pdfnames=[]
|
| 252 |
+
for i in range(len(tt[0])):
|
| 253 |
+
print("Value of tt[0] = ",tt[0][i])
|
| 254 |
+
pdfpath, _ = tsadropboxretrieval.getPathtoPDF_File(nameofPDF=tt[0][i])
|
| 255 |
+
dbx = tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 256 |
+
_, res = dbx.files_download(path=pdfpath)
|
| 257 |
+
pdf_bytes = res.content
|
| 258 |
+
pdflist.append(pdf_bytes)
|
| 259 |
+
pdfnames.append(pdfpath)
|
| 260 |
+
|
| 261 |
+
|
| 262 |
# 2. Generate in-memory Excel
|
| 263 |
+
print("pdflist = ",pdflist)
|
| 264 |
+
excel_io = Azure_api.detect_tables(pdflist,pdfnames)
|
| 265 |
# 3. Send it as a downloadable .xlsx
|
| 266 |
if excel_io is None:
|
| 267 |
# No tables → return a JSON error (or another response of your choice)
|