flask websocket port code example

Example 1: flask port

from flask import Flask

app = Flask(__name__)

if __name__ == '__main__':
      app.run(port=80)

# Also make sure that nothing else is running on port 80

Example 2: websockets socketio flask

<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf-8">
    var socket = io();
    socket.on('connect', function() {
        socket.emit('my event', {data: 'I\'m connected!'});
    });
</script>