Add getNodeInfoIndex route to Flask main.py
This commit is contained in:
@@ -16,7 +16,11 @@ def updateDataIndex():
|
|||||||
new_name = request.args.get('name', None)
|
new_name = request.args.get('name', None)
|
||||||
new_location = request.args.get('location', None)
|
new_location = request.args.get('location', None)
|
||||||
return updateData(node_id, new_name, new_location)
|
return updateData(node_id, new_name, new_location)
|
||||||
|
|
||||||
|
@app.route('/getNodeInfo')
|
||||||
|
def getNodeInfoIndex():
|
||||||
|
macAdress = request.args.get('macAdress', None)
|
||||||
|
return getNodeInfo(macAdress)
|
||||||
|
|
||||||
def updateData(node, name, location):
|
def updateData(node, name, location):
|
||||||
mydb = loginDB()
|
mydb = loginDB()
|
||||||
@@ -50,5 +54,16 @@ def getData(node, dataType, MAC):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def getNodeInfo(macAdress):
|
||||||
|
mydb = loginDB()
|
||||||
|
query = get_query(False, False, macAdress)
|
||||||
|
cursor = mydb.cursor(dictionary=True) # Enable dictionary output
|
||||||
|
cursor.execute(query)
|
||||||
|
result = cursor.fetchall() # Fetch the results
|
||||||
|
cursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, host='localhost')
|
app.run(debug=True, host='localhost')
|
||||||
|
Reference in New Issue
Block a user