Add getNodeInfoIndex route to Flask main.py

This commit is contained in:
sietse jonker
2024-03-26 19:42:29 +01:00
parent 93bf3aed37
commit 91f24a6f42

View File

@@ -17,6 +17,10 @@ def updateDataIndex():
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')