Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -160,6 +160,10 @@ def get_javascript_data(jsdata):
|
|
| 160 |
def searchDocument():
|
| 161 |
return render_template('wordSearch.html')
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
@app.route('/legends',methods=["GET", "POST"])
|
| 164 |
def legendDirectory():
|
| 165 |
return render_template('legendDirectory.html')
|
|
@@ -234,7 +238,27 @@ def getfromdropboxImg(jsdata):
|
|
| 234 |
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 235 |
_, buffer = cv2.imencode('.png', img)
|
| 236 |
return base64.b64encode(buffer).decode('utf-8')
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
@app.route('/savebase64Img/',methods=["POST"])
|
| 240 |
def stringToRGB():
|
|
|
|
| 160 |
def searchDocument():
|
| 161 |
return render_template('wordSearch.html')
|
| 162 |
|
| 163 |
+
@app.route('/tableDetection',methods=["GET", "POST"])
|
| 164 |
+
def TableDetection():
|
| 165 |
+
return render_template('tableDetection.html')
|
| 166 |
+
|
| 167 |
@app.route('/legends',methods=["GET", "POST"])
|
| 168 |
def legendDirectory():
|
| 169 |
return render_template('legendDirectory.html')
|
|
|
|
| 238 |
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 239 |
_, buffer = cv2.imencode('.png', img)
|
| 240 |
return base64.b64encode(buffer).decode('utf-8')
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
@app.route('/savedetectedtables/',methods=["POST"])
|
| 244 |
+
def table():
|
| 245 |
+
# 1. Get PDF bytes from Dropbox
|
| 246 |
+
tt = eval(request.form.get('answers')) # consider json.loads instead of eval
|
| 247 |
+
pdfpath, _ = tsadropboxretrieval.getPathtoPDF_File(nameofPDF=tt[0])
|
| 248 |
+
dbx = tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 249 |
+
_, res = dbx.files_download(path=pdfpath)
|
| 250 |
+
pdf_bytes = res.content
|
| 251 |
+
|
| 252 |
+
# 2. Generate in-memory Excel
|
| 253 |
+
excel_io = Azure_api.detect_tables(pdf_bytes)
|
| 254 |
+
print('type(excel_io) = ', type(excel_io))
|
| 255 |
+
# 3. Send it as a downloadable .xlsx
|
| 256 |
+
return send_file(
|
| 257 |
+
excel_io,
|
| 258 |
+
as_attachment=True,
|
| 259 |
+
download_name='detected_tables.xlsx',
|
| 260 |
+
mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
| 261 |
+
)
|
| 262 |
|
| 263 |
@app.route('/savebase64Img/',methods=["POST"])
|
| 264 |
def stringToRGB():
|