start db connection

This commit is contained in:
ishak jmilou.ishak
2024-12-04 17:46:40 +01:00
parent 606506e40c
commit f9cb54a1cf

View File

@@ -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)