IoT - Kubus
/
Kubus
JNP3 16/17
server/server.py
- Committer:
- Jan Kopa?ski
- Date:
- 2017-01-07
- Revision:
- 16:1569130916f1
- Child:
- 30:27c08888a838
File content as of revision 16:1569130916f1:
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()