title: How to use Flask-Sockets? Getting a KeyError: 'wsgi.websocket'
body: <p>I'm trying to use <a href="https://github.com/kennethreitz/flask-sockets">Flask-Sockets</a> with the example code:</p>
  
  <pre><code>sockets = Sockets(app)
  
  @sockets.route('/echo')
  def echo_socket(ws):
      while True:
          message = ws.receive()
          ws.send(message)
  </code></pre>
  
  <p>Unfortunately, when simply going to the url /echo using my browser it gives me an error saying:</p>
  
  <pre><code>File "/Library/Python/2.7/site-packages/Flask-0.10-py2.7.egg/flask/app.py", line 1836, in __call__
  return self.wsgi_app(environ, start_response)
  File "/Library/Python/2.7/site-packages/flask_sockets.py", line 37, in __call__
  environment = environ['wsgi.websocket']
  KeyError: 'wsgi.websocket'
  </code></pre>
  
  <p>Anybody any ideas what I'm doing wrong? All tips are welcome!</p>
  
  <p>[EDIT]
  @jbub - Thanks for the tips! So to start off I now use gunicorn instead of the built-in dev-server. So I started it using <code>gunicorn -k flask_sockets.worker -b 0.0.0.0:5000 main:app</code>. I then inserted the code below in my views.py i nwhich the echo_test.html is the code you supplied. When I now visit /echo_test, I indeed get a prompt saying "socket closed".</p>
  
  <pre><code>sockets = Sockets(app)
  
  @sockets.route('/echo')
  def echo_socket(ws):
      while True:
          message = ws.receive()
          ws.send(message)
  
  @app.route('/echo_test', methods=['GET'])
  def echo_test():
      return render_template('echo_test.html')
  </code></pre>
  
  <p>But let's say my aim is to have a word (randomly chosen from a list) on a page which gets updated with other values randomly chosen from the list. Would you have any tips on achieving that?</p>