IoT - Kubus
/
Kubus
JNP3 16/17
Diff: server/server.py
- Revision:
- 16:1569130916f1
- Child:
- 30:27c08888a838
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/server.py Sat Jan 07 02:12:25 2017 +0100 @@ -0,0 +1,26 @@ +from flask import Flask, jsonify +from coapserver import CoAPServer +from databaseconnector import DatabaseConnector + +app = Flask(__name__) + + +host = '46.101.12.31' +coapport = 5683 +database = 'kubus.db' +tables = ['pir1', 'pir2', 'distance', 'volume'] +connector = DatabaseConnector(database=database, tables=tables) + + +@app.route("/all") +def all(): + d = connector.read() + return jsonify(**d) + + +if __name__ == '__main__': + coapserver = CoAPServer(host, coapport, tables, connector) + coapserver.daemon = True + coapserver.start() + app.run(host=host) + coapserver.close() \ No newline at end of file