From 85dc94bf0c867cc9eed913c4f562166e64ee5c45 Mon Sep 17 00:00:00 2001 From: jh Date: Fri, 13 Sep 2019 18:16:27 -0700 Subject: [PATCH] jquery --- flaskr/app.py | 20 +++++++++++-------- flaskr/templates/index.html | 40 ++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/flaskr/app.py b/flaskr/app.py index 4dcb0e4..82bfc88 100644 --- a/flaskr/app.py +++ b/flaskr/app.py @@ -31,17 +31,21 @@ def create_flask_app(s2c, c2s, s2flask, args): pass s2flask.get() + @app.route('/save', methods=['POST']) + def save(): + send(s2c, 'save') + return '', 204 + + @app.route('/exit', methods=['POST']) + def exit(): + send(c2s, 'close') + request.environ.get('werkzeug.server.shutdown')() + return '', 204 + @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': - if 'save' in request.form: - send(s2c, 'save') - return '', 204 - elif 'exit' in request.form: - send(c2s, 'close') - request.environ.get('werkzeug.server.shutdown')() - return '', 204 - elif 'update' in request.form: + if 'update' in request.form: send_and_wait(c2s, 'update') elif 'next_preview' in request.form: send_and_wait(c2s, 'next_preview') diff --git a/flaskr/templates/index.html b/flaskr/templates/index.html index f445fe3..cf21304 100644 --- a/flaskr/templates/index.html +++ b/flaskr/templates/index.html @@ -1,14 +1,44 @@ + + + + + Flask Server Demonstration +

Flask Server Demonstration

- - - - - + + + + +