From: Olivier Tétard Date: Thu, 19 Nov 2015 14:08:05 +0000 (+0100) Subject: Ajout d’une nouvelle fonction AJAX pour envoyer les ordres X-Git-Url: http://olivier.miskin.fr/git/?a=commitdiff_plain;h=394b9f529b420379f8596998c38c957d0ebaa0c4;p=femtoblackweb.git Ajout d’une nouvelle fonction AJAX pour envoyer les ordres --- 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 () {