db = SQLAlchemy()
sockets = Sockets()
-
# @TODO
# for this to work, I have to put the following line at line 38 of
# flask_sockets, to inject it into the environment
bootstrap.init_app(app)
db.init_app(app)
sockets.init_app(app)
-
+
# maybe this sets the HTTP_SEC_WEBSOCKET_PROTOCOL ?
app.protocol_name = protocol_name
app.register_blueprint(admin_blueprint, url_prefix='/admin')
#from .core import coresocket
- from .core.command_sender import CommandSender
from .core.events import process_event
+ from .core.command_sender import CommandSender
+
+ sender = CommandSender()
+ sender.run()
@sockets.route('/api/v1/connection')
def coresocket(ws):
process_event(ws, event, sender)
#except Exception, e:
# print "Exception: %r" % e
-
- sender = CommandSender()
- sender.run()
return app
-from flask import Blueprint, render_template
+from flask import Blueprint, render_template, flash
+from flask.ext.wtf import Form
+from wtforms import StringField, TextAreaField, BooleanField, SelectField,\
+ SubmitField
from app.models.core import Device
+from app.core.commands import set_delivery_and_print
import pprint
main = Blueprint('main', __name__)
+class SendDeliveryForm(Form):
+ submit = SubmitField('Send Delivery')
+
@main.route('/')
def index():
devices = Device.query.all()
return render_template('index.html', devices=devices)
-@main.route('/device/<device_address>')
+@main.route('/device/<device_address>', methods=['GET', 'POST'])
def device(device_address):
device = Device.query.get_or_404(device_address)
-
- return render_template('dump.html', dump=pprint.pformat(device))
+ form = SendDeliveryForm()
+
+ if form.validate_on_submit():
+ flash('Form submitted')
+ #dc = set_delivery_and_print(device_address)
+ # now queue it, but where?
+ return render_template('dump.html', dump=pprint.pformat(device), form=form)