add some socket stuff

This commit is contained in:
Maxime Bloch 2019-09-20 17:16:45 +02:00
parent 4c282bc16b
commit 25f5a6417d
No known key found for this signature in database
GPG key ID: CE32A7D95B7D6418
3 changed files with 43 additions and 39 deletions

View file

@ -1 +1,2 @@
flask flask
python-socketio

View file

@ -1,3 +1,8 @@
const io = require('socket.io-client');
// or with import syntax
import io from 'socket.io-client'; import io from 'socket.io-client';
$(function() {
var socket = io();
socket.on('link_arrived', function(link_id) {
$('#current_run').append($('<div class="item>"</div>').text(link_id));
});
});

View file

@ -1,14 +1,11 @@
<html> <html>
<head> <head>
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet"> <link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
<script <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
type="text/javascript" <script src="https://code.jquery.com/jquery-1.11.1.js"></script>
src="{{ url_for('static', filename = 'hello.js') }}" <script type="text/javascript" src="{{ url_for('static', filename = 'index.js') }}"></script>
></script> <link rel="stylesheet" href="{{ url_for('static', filename = 'index.css') }}" />
<link
rel="stylesheet"
href="{{ url_for('static', filename = 'index.css') }}"
/>
</head> </head>
<body> <body>
@ -40,4 +37,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>