From 394b9f529b420379f8596998c38c957d0ebaa0c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20T=C3=A9tard?= Date: Thu, 19 Nov 2015 15:08:05 +0100 Subject: [PATCH] =?utf8?q?Ajout=20d=E2=80=99une=20nouvelle=20fonction=20AJ?= =?utf8?q?AX=20pour=20envoyer=20les=20ordres?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- femtoblackweb.py | 11 +++++++++++ templates/analyze_file.html | 2 ++ 2 files changed, 13 insertions(+) diff --git a/femtoblackweb.py b/femtoblackweb.py index fca80af..76f386d 100644 --- a/femtoblackweb.py +++ b/femtoblackweb.py @@ -9,6 +9,7 @@ from werkzeug import secure_filename from datetime import datetime from flask_bootstrap import Bootstrap +import socket import json @@ -122,5 +123,15 @@ def ajax_get_analysis(): except ValueError as e: abort(503) +@app.route('/ajax/run_orders/') +def ajax_run_orders(): + filename = request.args.get('filename') + + if filename != None: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(('127.0.0.1', 6667)) + sock.send(bytes(json.dumps({'top': filename}), 'utf-8')) + sock.close() + if __name__ == "__main__": app.run(debug=True) diff --git a/templates/analyze_file.html b/templates/analyze_file.html index fecf314..b7d3e44 100644 --- a/templates/analyze_file.html +++ b/templates/analyze_file.html @@ -69,6 +69,8 @@ function lancementOrdres() { clearInterval(interval); } }, periode); + + $.get('{{ url_for('ajax_run_orders') }}', {filename: '{{ filename }}'}); } document.addEventListener('DOMContentLoaded', function () { -- 2.30.2