mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 12:24:57 +00:00
start db connection
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user