Add DISABLE_GUI config
parent
d25308cfc5
commit
3ec3d4c581
|
@ -0,0 +1 @@
|
|||
*.pyc
|
10
main.py
10
main.py
|
@ -9,6 +9,7 @@ from spejsiot.rendering import render_endpoint
|
|||
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)-15s] %(name)-10s %(levelname)7s: %(message)s')
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.config['DISABLE_GUI'] = True
|
||||
app.config['PORT'] = 5000
|
||||
app.config['BROKER'] = ('mqtt.waw.hackerspace.pl', 1883)
|
||||
app.config['PREFIX'] = 'iot/'
|
||||
|
@ -24,6 +25,9 @@ def utility_processor():
|
|||
|
||||
@app.route('/')
|
||||
def index():
|
||||
if app.config.get('DISABLE_GUI'):
|
||||
flask.abort(404)
|
||||
|
||||
return flask.render_template('index.html', devices=manager.devices)
|
||||
|
||||
@app.route('/api/1/devices/')
|
||||
|
@ -42,11 +46,13 @@ def api_device_info(node_id):
|
|||
@app.route('/api/1/device/<node_id>/<endpoint>/<prop>/<value>')
|
||||
@app.route('/api/1/devices/<node_id>/<endpoint>/<prop>/<value>')
|
||||
def device_write(node_id, endpoint, prop, value):
|
||||
return flask.jsonify(manager.handle_request(node_id, endpoint, prop, value))
|
||||
return flask.jsonify({
|
||||
"result": manager.handle_request(node_id, endpoint, prop, value)
|
||||
})
|
||||
|
||||
@app.route('/api/1/devices/<node_id>/<endpoint>/<prop>', methods=['PUT'])
|
||||
def device_put(node_id, endpoint, prop):
|
||||
return flask.jsonify(manager.handle_request(node_id, endpoint, prop, flask.request.json['value']))
|
||||
return device_write(node_id, endpoint, prop, flask.request.json['value'])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -88,4 +88,3 @@ class SpejsiotManager(mqtt.Client):
|
|||
|
||||
def on_log(self, client, userdata, level, buf):
|
||||
self.logger.debug('[%r] %r', level, buf)
|
||||
|
||||
|
|
Loading…
Reference in New Issue