Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,9 +26,13 @@ from urllib.parse import unquote
|
|
| 26 |
import API
|
| 27 |
import MC_Templates_API
|
| 28 |
import tsadropboxretrieval
|
|
|
|
| 29 |
|
| 30 |
app = Flask(__name__)
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
@app.route('/getprojectnames/',methods=['GET'])
|
| 34 |
def getprjnamesfromTestAPI():
|
|
@@ -47,7 +51,7 @@ def getprjSectionsfromTestAPI(jsdata):
|
|
| 47 |
return jsonify(sections)
|
| 48 |
|
| 49 |
|
| 50 |
-
#retrieves
|
| 51 |
@app.route('/getmethod/<jsdata>',methods=['GET','POST'])
|
| 52 |
def get_javascript_data(jsdata):
|
| 53 |
#get project from the first dropdown
|
|
@@ -58,6 +62,41 @@ def get_javascript_data(jsdata):
|
|
| 58 |
else:
|
| 59 |
return ['No projects found']
|
| 60 |
#---------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
@app.route('/RetrieveMCTNames/<jsdata>',methods=['GET'])
|
| 63 |
def CallAPIforMCTNames(jsdata):
|
|
@@ -65,17 +104,7 @@ def CallAPIforMCTNames(jsdata):
|
|
| 65 |
DictionaryOfTemplates=MC_Templates_API.RetrieveMC_Templates_API()
|
| 66 |
jsdata=jsdata.replace('"', '')
|
| 67 |
return jsonify(DictionaryOfTemplates[str(jsdata).lower()])
|
| 68 |
-
#get projects of 'project name'
|
| 69 |
|
| 70 |
-
#_________________________________________________________________________________________________________________________
|
| 71 |
-
#_________________________________________________________________________________________________________________________
|
| 72 |
-
#NOT IMP NOW
|
| 73 |
-
#retrieve all info of elements after clicking 'measure' button
|
| 74 |
-
@app.route("/",methods=["GET", "POST"])
|
| 75 |
-
def getInfotoMeasure():
|
| 76 |
-
# db.create_folder()
|
| 77 |
-
mylist=[1,2,3,4]
|
| 78 |
-
return render_template("proposed-GUI.html",mylist=mylist)
|
| 79 |
#_________________________________________________________________________________________________________________________
|
| 80 |
#_________________________________________________________________________________________________________________________
|
| 81 |
#Hex value to RGB value
|
|
@@ -278,6 +307,15 @@ def getimg(jsdata):
|
|
| 278 |
|
| 279 |
#_________________________________________________________________________________________________________________________
|
| 280 |
#_________________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
#DELETE MARKUPS (for comparison)
|
| 282 |
@app.route('/_submission',methods=["GET", "POST"])
|
| 283 |
def getnewlegend():
|
|
@@ -364,5 +402,6 @@ def returnAPITables():
|
|
| 364 |
|
| 365 |
#_________________________________________________________________________________________________________________________
|
| 366 |
#_________________________________________________________________________________________________________________________
|
|
|
|
| 367 |
if __name__ == "__main__":
|
| 368 |
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 26 |
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():
|
|
|
|
| 51 |
return jsonify(sections)
|
| 52 |
|
| 53 |
|
| 54 |
+
#retrieves projects
|
| 55 |
@app.route('/getmethod/<jsdata>',methods=['GET','POST'])
|
| 56 |
def get_javascript_data(jsdata):
|
| 57 |
#get project from the first dropdown
|
|
|
|
| 62 |
else:
|
| 63 |
return ['No projects found']
|
| 64 |
#---------------------------------------------------------------
|
| 65 |
+
@app.route('/WordSearch',methods=["GET", "POST"])
|
| 66 |
+
def searchDocument():
|
| 67 |
+
return render_template('wordSearch.html')
|
| 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')
|
| 75 |
+
listpfProjs=values.get('listofprojs')
|
| 76 |
+
print(keyword,listpfProjs)
|
| 77 |
+
df,img_list=doc_search.search_docs(keyword,listpfProjs)
|
| 78 |
+
for img in img_list:
|
| 79 |
+
_, buffer = cv2.imencode('.png', img)
|
| 80 |
+
arr.append(base64.b64encode(buffer).decode('utf-8'))
|
| 81 |
+
return jsonify([df.to_html(index=False, escape=False),arr])
|
| 82 |
+
|
| 83 |
+
@app.route('/searchInFolder',methods=["GET", "POST"])
|
| 84 |
+
def getSearchinFolder():
|
| 85 |
+
arr=[]
|
| 86 |
+
values = request.get_json()
|
| 87 |
+
keyword=values.get('keyword')
|
| 88 |
+
projname=values.get('ProjectName')
|
| 89 |
+
df,img_list=doc_search.slow_search(keyword=keyword,project=projname)
|
| 90 |
+
for img in img_list:
|
| 91 |
+
_, buffer = cv2.imencode('.png', img)
|
| 92 |
+
arr.append(base64.b64encode(buffer).decode('utf-8'))
|
| 93 |
+
return jsonify([df.to_html(index=False, escape=False),arr])
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
@app.route("/measurementConsole",methods=["GET", "POST"])
|
| 98 |
+
def measurementConsoleFn():
|
| 99 |
+
return render_template("proposed-GUI.html")
|
| 100 |
|
| 101 |
@app.route('/RetrieveMCTNames/<jsdata>',methods=['GET'])
|
| 102 |
def CallAPIforMCTNames(jsdata):
|
|
|
|
| 104 |
DictionaryOfTemplates=MC_Templates_API.RetrieveMC_Templates_API()
|
| 105 |
jsdata=jsdata.replace('"', '')
|
| 106 |
return jsonify(DictionaryOfTemplates[str(jsdata).lower()])
|
|
|
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
#_________________________________________________________________________________________________________________________
|
| 109 |
#_________________________________________________________________________________________________________________________
|
| 110 |
#Hex value to RGB value
|
|
|
|
| 307 |
|
| 308 |
#_________________________________________________________________________________________________________________________
|
| 309 |
#_________________________________________________________________________________________________________________________
|
| 310 |
+
#get sunburst from doc_search
|
| 311 |
+
@app.route('/getsunburst',methods=["GET", "POST"])
|
| 312 |
+
def getSunburst():
|
| 313 |
+
|
| 314 |
+
# df=tsadropboxretrieval.GetParquetDF()
|
| 315 |
+
tree=doc_search.prepare_sunburst()
|
| 316 |
+
return jsonify(tree.to_dict())
|
| 317 |
+
#_________________________________________________________________________________________________________________________
|
| 318 |
+
#_________________________________________________________________________________________________________________________
|
| 319 |
#DELETE MARKUPS (for comparison)
|
| 320 |
@app.route('/_submission',methods=["GET", "POST"])
|
| 321 |
def getnewlegend():
|
|
|
|
| 402 |
|
| 403 |
#_________________________________________________________________________________________________________________________
|
| 404 |
#_________________________________________________________________________________________________________________________
|
| 405 |
+
|
| 406 |
if __name__ == "__main__":
|
| 407 |
app.run(host="0.0.0.0", port=7860)
|