Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -136,6 +136,29 @@ def hexRGB(color):
|
|
| 136 |
return color
|
| 137 |
#_________________________________________________________________________________________________________________________
|
| 138 |
#_________________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
@app.route('/savebase64Img/',methods=["POST"])
|
| 140 |
def stringToRGB():
|
| 141 |
vv = eval(request.form.get('answers'))
|
|
@@ -381,6 +404,7 @@ def get_pdf(jsdata):
|
|
| 381 |
|
| 382 |
# Download PDF from Dropbox
|
| 383 |
pdfpath,pdflink=tsadropboxretrieval.getPathtoPDF_File(nameofPDF=jsdata)
|
|
|
|
| 384 |
dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 385 |
md, res =dbxTeam.files_download(path=pdfpath)
|
| 386 |
|
|
@@ -696,6 +720,8 @@ def cvtSummarytoXML(jsdata):
|
|
| 696 |
# print(result[1])
|
| 697 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 698 |
return jsonify(xmllink)
|
|
|
|
|
|
|
| 699 |
|
| 700 |
#_________________________________________________________________________________________________________________________
|
| 701 |
#_________________________________________________________________________________________________________________________
|
|
|
|
| 136 |
return color
|
| 137 |
#_________________________________________________________________________________________________________________________
|
| 138 |
#_________________________________________________________________________________________________________________________
|
| 139 |
+
@app.route('/updatepreviewimg/<jsdata>',methods=["GET", "POST"])
|
| 140 |
+
def getfromdropboxImg(jsdata):
|
| 141 |
+
# vv = eval(request.form.get('pdflink'))
|
| 142 |
+
pdfpath=''
|
| 143 |
+
# jsdata=jsdata.replace('"', '')
|
| 144 |
+
jsdata=eval(jsdata)
|
| 145 |
+
print('pdfnameeee==',jsdata)
|
| 146 |
+
|
| 147 |
+
dbPath='/TSA JOBS/ADR Test/'+jsdata[0][0]+'/'+jsdata[0][1]+'/'+jsdata[0][2]+'/Measured Plan/'+jsdata[1]
|
| 148 |
+
print(dbPath)
|
| 149 |
+
dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 150 |
+
md, res =dbxTeam.files_download(path=dbPath)
|
| 151 |
+
data = res.content
|
| 152 |
+
doc = fitz.open("pdf",data)
|
| 153 |
+
page=doc[0]
|
| 154 |
+
pix = page.get_pixmap(dpi=300) # render page to an image
|
| 155 |
+
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 156 |
+
img=np.array(pl)
|
| 157 |
+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 158 |
+
_, buffer = cv2.imencode('.png', img)
|
| 159 |
+
return base64.b64encode(buffer).decode('utf-8')
|
| 160 |
+
|
| 161 |
+
|
| 162 |
@app.route('/savebase64Img/',methods=["POST"])
|
| 163 |
def stringToRGB():
|
| 164 |
vv = eval(request.form.get('answers'))
|
|
|
|
| 404 |
|
| 405 |
# Download PDF from Dropbox
|
| 406 |
pdfpath,pdflink=tsadropboxretrieval.getPathtoPDF_File(nameofPDF=jsdata)
|
| 407 |
+
print('pdfpath',pdfpath)
|
| 408 |
dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 409 |
md, res =dbxTeam.files_download(path=pdfpath)
|
| 410 |
|
|
|
|
| 720 |
# print(result[1])
|
| 721 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 722 |
return jsonify(xmllink)
|
| 723 |
+
|
| 724 |
+
|
| 725 |
|
| 726 |
#_________________________________________________________________________________________________________________________
|
| 727 |
#_________________________________________________________________________________________________________________________
|