From f9cb54a1cf9e96211c3b8d2bea45f7ca4b344ca7 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Wed, 4 Dec 2024 17:46:40 +0100 Subject: [PATCH] start db connection --- src/Python/flask/web/app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index 3fc45f6..cb9978e 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -1,5 +1,6 @@ from flask import Flask, request, render_template, jsonify import paho.mqtt.client as mqtt +import mariadb app = Flask(__name__) @@ -17,6 +18,15 @@ mqtt_client.loop_start() mqtt_client.subscribe("kobuki/data") mqtt_client.on_message = on_message # this lines needs to be under the function definition otherwise it cant find which function it needs to use +conn = mariadb.connect( + host='127.0.0.1', + port= 3306, + user='admin', + password='kobuki', + database='kobuki') +cur = conn.cursor() + + @app.route('/') def index(): return render_template('index.html') @@ -50,7 +60,9 @@ def phpmyadmin_passthrough(path): # Laat Apache deze route direct afhandelen return "", 404 - +@app.route("/index") +def index(): + return "Connected to database" if __name__ == '__main__': app.run(debug=True, port=5000)