Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,16 +27,25 @@ import API
|
|
| 27 |
import MC_Templates_API
|
| 28 |
import tsadropboxretrieval
|
| 29 |
import doc_search
|
|
|
|
| 30 |
|
| 31 |
app = Flask(__name__)
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
@app.route("/",methods=["GET", "POST"])
|
| 34 |
def getInfotoMeasure():
|
|
|
|
| 35 |
return render_template("proposed-GUI.html")
|
| 36 |
|
| 37 |
@app.route('/getprojectnames/',methods=['GET'])
|
| 38 |
def getprjnamesfromTestAPI():
|
| 39 |
prjnames=API.getPrjNames()
|
|
|
|
| 40 |
return jsonify(prjnames)
|
| 41 |
|
| 42 |
@app.route('/getprojectparts/<jsdata>',methods=['GET'])
|
|
@@ -68,7 +77,6 @@ def searchDocument():
|
|
| 68 |
|
| 69 |
@app.route('/searchInDocs',methods=["GET", "POST"])
|
| 70 |
def getSearchinDocs():
|
| 71 |
-
print('cvbnm,')
|
| 72 |
arr=[]
|
| 73 |
values = request.get_json()
|
| 74 |
keyword=values.get('keyword')
|
|
@@ -368,7 +376,9 @@ def dltmarkupslegend():
|
|
| 368 |
#get pdf dropbox url after measurement is done
|
| 369 |
@app.route('/getdropboxurl/<jsdata>',methods=["GET", "POST"])
|
| 370 |
def calldropboxurl(jsdata):
|
|
|
|
| 371 |
pdfurl=tsadropboxretrieval.getPathtoPDF_File(nameofPDF=jsdata)[1]
|
|
|
|
| 372 |
return jsonify(pdfurl)
|
| 373 |
|
| 374 |
#_________________________________________________________________________________________________________________________
|
|
@@ -394,6 +404,45 @@ def returnAPITables():
|
|
| 394 |
# API.update_df()
|
| 395 |
table1,table2,table3=API.GenerateTables()
|
| 396 |
return jsonify([table1.to_dict(),table2.to_dict(),table3.to_dict()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
#_________________________________________________________________________________________________________________________
|
| 398 |
#_________________________________________________________________________________________________________________________
|
| 399 |
|
|
|
|
| 27 |
import MC_Templates_API
|
| 28 |
import tsadropboxretrieval
|
| 29 |
import doc_search
|
| 30 |
+
import threading
|
| 31 |
|
| 32 |
app = Flask(__name__)
|
| 33 |
|
| 34 |
+
|
| 35 |
+
prjnamesURL= 'https://docs.google.com/spreadsheets/d/1I4P7wiCXTAwnld0YQfUJC8bPtuiETna1HGWVuHbuDBk/edit#gid=0'
|
| 36 |
+
prjpartsURL= 'https://docs.google.com/spreadsheets/d/1I4P7wiCXTAwnld0YQfUJC8bPtuiETna1HGWVuHbuDBk/edit#gid=2102042200'
|
| 37 |
+
prjsectionsURL= 'https://docs.google.com/spreadsheets/d/1I4P7wiCXTAwnld0YQfUJC8bPtuiETna1HGWVuHbuDBk/edit#gid=1708565170'
|
| 38 |
+
|
| 39 |
+
|
| 40 |
@app.route("/",methods=["GET", "POST"])
|
| 41 |
def getInfotoMeasure():
|
| 42 |
+
API.AppendtablestoSheets()
|
| 43 |
return render_template("proposed-GUI.html")
|
| 44 |
|
| 45 |
@app.route('/getprojectnames/',methods=['GET'])
|
| 46 |
def getprjnamesfromTestAPI():
|
| 47 |
prjnames=API.getPrjNames()
|
| 48 |
+
# API.AppendtablestoSheets()
|
| 49 |
return jsonify(prjnames)
|
| 50 |
|
| 51 |
@app.route('/getprojectparts/<jsdata>',methods=['GET'])
|
|
|
|
| 77 |
|
| 78 |
@app.route('/searchInDocs',methods=["GET", "POST"])
|
| 79 |
def getSearchinDocs():
|
|
|
|
| 80 |
arr=[]
|
| 81 |
values = request.get_json()
|
| 82 |
keyword=values.get('keyword')
|
|
|
|
| 376 |
#get pdf dropbox url after measurement is done
|
| 377 |
@app.route('/getdropboxurl/<jsdata>',methods=["GET", "POST"])
|
| 378 |
def calldropboxurl(jsdata):
|
| 379 |
+
print(jsdata)
|
| 380 |
pdfurl=tsadropboxretrieval.getPathtoPDF_File(nameofPDF=jsdata)[1]
|
| 381 |
+
print(pdfurl)
|
| 382 |
return jsonify(pdfurl)
|
| 383 |
|
| 384 |
#_________________________________________________________________________________________________________________________
|
|
|
|
| 404 |
# API.update_df()
|
| 405 |
table1,table2,table3=API.GenerateTables()
|
| 406 |
return jsonify([table1.to_dict(),table2.to_dict(),table3.to_dict()])
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
@app.route('/refreshAPI',methods=["GET", "POST"])
|
| 410 |
+
def checktables():
|
| 411 |
+
table1,table2,table3=API.GenerateTables()
|
| 412 |
+
url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 413 |
+
url_2 = prjpartsURL.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 414 |
+
url_3 = prjsectionsURL.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 415 |
+
|
| 416 |
+
table1N = pd.read_csv(url_1)
|
| 417 |
+
table2N = pd.read_csv(url_2)
|
| 418 |
+
table3N = pd.read_csv(url_3)
|
| 419 |
+
|
| 420 |
+
t1Diff=table1N[~table1N.isin(table1)].dropna()
|
| 421 |
+
t2Diff=table2N[~table2N.isin(table2)].dropna()
|
| 422 |
+
t3Diff=table3N[~table3N.isin(table3)].dropna()
|
| 423 |
+
returnString=''
|
| 424 |
+
if not t1Diff.empty:
|
| 425 |
+
returnString=['Changes have been made in Projects. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','project']
|
| 426 |
+
if not t2Diff.empty:
|
| 427 |
+
returnString=['Changes have been made in Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','part']
|
| 428 |
+
if not t3Diff.empty:
|
| 429 |
+
returnString=['Changes have been made in Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','section']
|
| 430 |
+
if (not t1Diff.empty) and (not t2Diff.empty):
|
| 431 |
+
returnString=['Changes have been made in Projects and Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','projectpart']
|
| 432 |
+
if (not t1Diff.empty) and (not t3Diff.empty):
|
| 433 |
+
returnString=['Changes have been made in Projects and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','projectsection']
|
| 434 |
+
if (not t2Diff.empty) and (not t3Diff.empty):
|
| 435 |
+
returnString=['Changes have been made in Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','partsection']
|
| 436 |
+
print(t1Diff)
|
| 437 |
+
return jsonify(returnString)
|
| 438 |
+
|
| 439 |
+
@app.route('/refreshAPIAppendNewTables',methods=["GET", "POST"])
|
| 440 |
+
def appendNewTables():
|
| 441 |
+
value = request.args.get('keyword')
|
| 442 |
+
print(value)
|
| 443 |
+
API.AppendtablestoSheets()
|
| 444 |
+
return jsonify('appended')
|
| 445 |
+
|
| 446 |
#_________________________________________________________________________________________________________________________
|
| 447 |
#_________________________________________________________________________________________________________________________
|
| 448 |
|