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