Basic flask-socketio implementation not working; no output or errors Basic flask-socketio implementation not working; no output or errors flask flask

Basic flask-socketio implementation not working; no output or errors


In trying to reproduce your problem with the setup given, I noticed the following error in the Javascript console:

scan.js:1 Uncaught ReferenceError: $ is not defined    at scan.js:1

Your example doesn't have jQuery loaded, so your scan.js isn't able to connect to the socket when the document is finished loading.

You can add jQuery by including the CDN reference below:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

And then we see the example works:

127.0.0.1 - - [2018-02-12 07:53:58] "GET /scan/ HTTP/1.1" 200 521 0.010458127.0.0.1 - - [2018-02-12 07:53:58] "GET /static/css/scan.css HTTP/1.1" 404 342 0.001086127.0.0.1 - - [2018-02-12 07:53:58] "GET /static/css/scan.css HTTP/1.1" 404 342 0.000776127.0.0.1 - - [2018-02-12 07:53:58] "GET /socket.io/?EIO=3&transport=polling&t=1518393238311-0 HTTP/1.1" 200 345 0.000879Client connected127.0.0.1 - - [2018-02-12 07:53:58] "POST /socket.io/?EIO=3&transport=polling&t=1518393238776-1&sid=7d98901d0ef74164975ee5464879ba19 HTTP/1.1" 200 195 0.000818127.0.0.1 - - [2018-02-12 07:53:58] "GET /socket.io/?EIO=3&transport=polling&t=1518393238778-2&sid=7d98901d0ef74164975ee5464879ba19 HTTP/1.1" 200 198 0.000201