41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
from flask import Flask, request
|
|
import mysql.connector
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def index():
|
|
# return getData()
|
|
nodeNumber = request.args.get('nodenumber', default = None)
|
|
nodeList = request.args.get('nodeList', default = None)
|
|
# return nodeNumber
|
|
return nodeList
|
|
|
|
|
|
def getData():
|
|
try:
|
|
mydb = mysql.connector.connect(
|
|
host="localhost",
|
|
user="root",
|
|
password="Dingleberries69!",
|
|
database="NodeData"
|
|
)
|
|
|
|
cursor = mydb.cursor()
|
|
query = "SELECT * FROM `Measurement`"
|
|
cursor.execute(query)
|
|
result = cursor.fetchall() # Fetch the results
|
|
|
|
# Convert the results to a string for display
|
|
result_str = ', '.join([str(row) for row in result])
|
|
|
|
cursor.close()
|
|
mydb.close()
|
|
|
|
return result
|
|
except mysql.connector.Error as err:
|
|
print("MySQL Error:", err)
|
|
return "MySQL Error: " + str(err)
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True, host='localhost') |