diff --git a/doorlockd-new/doorlockd.py b/doorlockd-new/doorlockd.py index 03a13eb..b6844bc 100755 --- a/doorlockd-new/doorlockd.py +++ b/doorlockd-new/doorlockd.py @@ -80,7 +80,7 @@ class DoorState(Enum): led = 'red' if self == DoorState.Open: led = 'green' - return '' % led + return 'static/led-%s.png' % led def to_html(self): if self == DoorState.Open: @@ -258,7 +258,7 @@ def home(): authentication_form=authentication_form, response=response, state_text=logic.state.to_html(), - state_img=Markup(logic.state.to_img()), + led=logic.state.to_img(), title=html_title) @@ -270,6 +270,6 @@ if __name__ == '__main__': logic = Logic() - socketio.run(webapp, port=8080) + socketio.run(webapp, host='0.0.0.0', port=8080) sys.exit(0) diff --git a/doorlockd-new/templates/display.html b/doorlockd-new/templates/display.html index 2cd3472..ceff515 100644 --- a/doorlockd-new/templates/display.html +++ b/doorlockd-new/templates/display.html @@ -10,7 +10,7 @@ socket.emit('connected'); }); socket.on('status', function(status) { - $('#led').html(status.led) + $('#led').attr('src', status.led) $('#message').html(status.message) }); }); @@ -21,7 +21,7 @@

Willkommen in der Binary Kitchen!

-
+
diff --git a/doorlockd-new/templates/formhelpers.html b/doorlockd-new/templates/formhelpers.html deleted file mode 100644 index 69a0ae4..0000000 --- a/doorlockd-new/templates/formhelpers.html +++ /dev/null @@ -1,24 +0,0 @@ -{% macro render_field_label(field) %} -
{{ field.label }} -
{{ field(**kwargs)|safe }} - {% if field.errors %} -
    - {% for error in field.errors %} -
  • {{ error }}
  • - {% endfor %} -
- {% endif %} -
-{% endmacro %} - -{% macro render_field(field) %} -
{{ field(**kwargs)|safe }} - {% if field.errors %} -
    - {% for error in field.errors %} -
  • {{ error }}
  • - {% endfor %} -
- {% endif %} -
-{% endmacro %} diff --git a/doorlockd-new/templates/index.html b/doorlockd-new/templates/index.html index 0a59f16..ab0278b 100644 --- a/doorlockd-new/templates/index.html +++ b/doorlockd-new/templates/index.html @@ -1,56 +1,21 @@ -{% from "formhelpers.html" import render_field_label, render_field %} - - - -{{ title }} - - - +{% extends "layout.html" %} +{% import "bootstrap/wtf.html" as wtf %} - - - {{ state_img }} -
- {{ render_field_label(authentication_form.username) }} - {{ render_field_label(authentication_form.password) }} +{% block content %} +

Binary Kitchen Doorlock

+
+
+ +
+
+ {{ wtf.quick_form(authentication_form, button_map={'open': 'success btn-lg btn-block', 'close': 'danger btn-lg btn-block'}) }} + {% if response %}
- {{ render_field(authentication_form.open) }} - {{ render_field(authentication_form.close) }} - {{ authentication_form.csrf_token }} - - {% if response %} -
-

{{ response.to_html() }}

- {% endif %} -
- Die Kitchen ist: {{ state_text }} - - +

{{ response.to_html() }}

+ {% endif %} +
+ Die Kitchen ist: {{ state_text }} +
+
+{{ super() }} +{% endblock %}