Changed existing websocket examples to take a port
This commit is contained in:
parent
0d4f448500
commit
64c065b3d1
@ -5,7 +5,7 @@
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var data = {};
|
||||
var s = new WebSocket("ws://127.0.0.1:7000/chat");
|
||||
var s = new WebSocket("ws://127.0.0.1:%(port)s/chat");
|
||||
s.onopen = function() {
|
||||
s.send('New participant joined');
|
||||
};
|
||||
|
@ -4,6 +4,8 @@ import eventlet
|
||||
from eventlet import wsgi
|
||||
from eventlet import websocket
|
||||
|
||||
PORT = 7000
|
||||
|
||||
participants = set()
|
||||
|
||||
@websocket.WebSocketWSGI
|
||||
@ -27,10 +29,10 @@ def dispatch(environ, start_response):
|
||||
start_response('200 OK', [('content-type', 'text/html')])
|
||||
return [open(os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'websocket_chat.html')).read()]
|
||||
'websocket_chat.html')).read() % PORT]
|
||||
|
||||
if __name__ == "__main__":
|
||||
# run an example app from the command line
|
||||
listener = eventlet.listen(('127.0.0.1', 7000))
|
||||
listener = eventlet.listen(('127.0.0.1', PORT))
|
||||
print "\nVisit http://localhost:7000/ in your websocket-capable browser.\n"
|
||||
wsgi.server(listener, dispatch)
|
||||
|
Loading…
Reference in New Issue
Block a user