title: How to have Sanic respond with http and ws?
body: <p>I have the following code for a Sanic hello world based off combining different endpoints here:</p>
  
  <ul>
  <li><a href="https://sanic.readthedocs.io/en/latest/sanic/response.html" rel="nofollow noreferrer">https://sanic.readthedocs.io/en/latest/sanic/response.html</a></li>
  <li><a href="https://sanic.readthedocs.io/en/latest/sanic/websocket.html" rel="nofollow noreferrer">https://sanic.readthedocs.io/en/latest/sanic/websocket.html</a></li>
  </ul>
  
  <p>Code is:</p>
  
  <pre><code>from sanic import Sanic
  from sanic import response
  from sanic.websocket import WebSocketProtocol
  
  app = Sanic()
  
  @app.route("/")
  async def test(request):
      return response.json({"hello": "world"})
  
  
  @app.route('/html')
  async def handle_request(request):
      return response.html('&lt;p&gt;Hello world!&lt;/p&gt;')
  
  @app.websocket('/feed')
  async def feed(request, ws):
      while True:
          data = 'hello!'
          print('Sending: ' + data)
          await ws.send(data)
          data = await ws.recv()
          print('Received: ' + data)
  
  @app.route('/html2')
  async def handle_request(request):
    return response.html("""&lt;html&gt;&lt;head&gt;&lt;script&gt;
           var exampleSocket = new WebSocket("wss://0.0.0.0:8000/feed",      "protocolOne");
           exampleSocket.onmessage = function (event) {
           console.log(event.data)};&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Hello socket!&lt;/h1&gt;&lt;p&gt;hello&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;""")
  
  app.run(host="0.0.0.0", port=8000)
  # app.run(host="0.0.0.0", port=8000, protocol=WebSocketProtocol)    # ws 
  </code></pre>
  
  <p>The routes "/" and "/html" work fine, but </p>
  
  <pre><code>http://0.0.0.0:8000/feed
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>Error: Invalid websocket request
  </code></pre>
  
  <p>and "/html2" renders the page fine, but doesn't log to console, showing in the debugger:</p>
  
  <pre><code>Firefox can’t establish a connection to the server at wss://0.0.0.0:8000/feed.
  </code></pre>
  
  <p>What should I change or add to make a viable websocket endpoint that plays nicely with the http ones, too?</p>