mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Fixed websockets to not use a hardcoded localhost.
This commit is contained in:
parent
51f1f22665
commit
bb2f51ccda
@ -8,7 +8,7 @@ http://assorted.svn.sourceforge.net/viewvc/assorted/real-time-plotter/trunk/src/
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var data = {};
|
||||
var s = new WebSocket("ws://localhost:8000/data");
|
||||
var s = new WebSocket("ws://nebula:8000/data");
|
||||
s.onopen = function() {
|
||||
//alert('open');
|
||||
s.send('hi');
|
||||
@ -41,4 +41,4 @@ window.onload = function() {
|
||||
<h3>Plot</h3>
|
||||
<div id="holder" style="width:600px;height:300px"></div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@ -15,9 +15,8 @@ import eventlet
|
||||
from eventlet.common import get_errno
|
||||
|
||||
class WebSocketWSGI(object):
|
||||
def __init__(self, handler, origin):
|
||||
def __init__(self, handler):
|
||||
self.handler = handler
|
||||
self.origin = origin
|
||||
|
||||
def verify_client(self, ws):
|
||||
pass
|
||||
@ -28,7 +27,7 @@ class WebSocketWSGI(object):
|
||||
# need to check a few more things here for true compliance
|
||||
start_response('400 Bad Request', [('Connection','close')])
|
||||
return []
|
||||
|
||||
|
||||
sock = environ['wsgi.input'].get_socket()
|
||||
ws = WebSocket(sock,
|
||||
environ.get('HTTP_ORIGIN'),
|
||||
@ -40,7 +39,7 @@ class WebSocketWSGI(object):
|
||||
"Connection: Upgrade\r\n"
|
||||
"WebSocket-Origin: %s\r\n"
|
||||
"WebSocket-Location: ws://%s%s\r\n\r\n" % (
|
||||
self.origin,
|
||||
environ.get('HTTP_ORIGIN'),
|
||||
environ.get('HTTP_HOST'),
|
||||
ws.path))
|
||||
sock.sendall(handshake_reply)
|
||||
@ -132,7 +131,7 @@ def handle(ws):
|
||||
ws.send("0 %s %s\n" % (i, random.random()))
|
||||
eventlet.sleep(0.1)
|
||||
|
||||
wsapp = WebSocketWSGI(handle, 'http://localhost:8000')
|
||||
wsapp = WebSocketWSGI(handle)
|
||||
def app(environ, start_response):
|
||||
""" This resolves to the web page or the websocket depending on
|
||||
the path."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user