Compare commits
No commits in common. '768a10de966f08070d654cb66b1c3bf4ae8e8ff9' and 'd31097d0d7d36727db59b56efbb70090d058c5e9' have entirely different histories.
768a10de96
...
d31097d0d7
@ -1 +0,0 @@
|
|||||||
SQLHandler/config.json
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class sensor():
|
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
# This file contains the function to connect to a secified database.
|
|
||||||
import json
|
|
||||||
import mysql.connector
|
|
||||||
from Util import configuration as decryption
|
|
||||||
|
|
||||||
# Open the config file and readout the data
|
|
||||||
with open('config.json', 'r') as file:
|
|
||||||
data = file.read()
|
|
||||||
config = json.loads(data)
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------------------------------------------------------------------------- #
|
|
||||||
def createConnection(configuration):
|
|
||||||
"""
|
|
||||||
It creates the connection to the database
|
|
||||||
:param configuration: This specifies which configuration should be used
|
|
||||||
:return: It returns the database connection
|
|
||||||
"""
|
|
||||||
connection = mysql.connector.connect(
|
|
||||||
host=config[configuration]["host"],
|
|
||||||
user=config[configuration]["user"],
|
|
||||||
password=decryption.decryptKey(config[configuration]["passwd"]),
|
|
||||||
database=config[configuration]["dbname"],
|
|
||||||
autocommit=True
|
|
||||||
)
|
|
||||||
return connection
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
from flask import Flask, jsonify, request
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/sensordata')
|
|
||||||
def get_sensordata():
|
|
||||||
return jsonify(sensordata)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/sensordata', methods=['POST'])
|
|
||||||
def add_sensordata():
|
|
||||||
|
|
||||||
sensordata.append(request.get_json())
|
|
||||||
|
|
||||||
return '', 204
|
|
||||||
Loading…
Reference in New Issue