##// END OF EJS Templates
remove superfluous ws-hostname parameter from notebook...
MinRK -
Show More
@@ -139,7 +139,15 class AuthenticatedHandler(web.RequestHandler):
139 return True
139 return True
140 else:
140 else:
141 return False
141 return False
142
143 @property
144 def ws_url(self):
145 """websocket url matching the current request
142
146
147 turns http[s]://host[:port]/foo/bar into
148 ws[s]://host[:port]/foo/bar
149 """
150 return self.request.headers.get('Origin').replace('http', 'ws', 1)
143
151
144
152
145 class ProjectDashboardHandler(AuthenticatedHandler):
153 class ProjectDashboardHandler(AuthenticatedHandler):
@@ -221,8 +229,7 class MainKernelHandler(AuthenticatedHandler):
221 km = self.application.kernel_manager
229 km = self.application.kernel_manager
222 notebook_id = self.get_argument('notebook', default=None)
230 notebook_id = self.get_argument('notebook', default=None)
223 kernel_id = km.start_kernel(notebook_id)
231 kernel_id = km.start_kernel(notebook_id)
224 ws_url = self.application.ipython_app.get_ws_url()
232 data = {'ws_url':self.ws_url,'kernel_id':kernel_id}
225 data = {'ws_url':ws_url,'kernel_id':kernel_id}
226 self.set_header('Location', '/'+kernel_id)
233 self.set_header('Location', '/'+kernel_id)
227 self.finish(jsonapi.dumps(data))
234 self.finish(jsonapi.dumps(data))
228
235
@@ -249,8 +256,7 class KernelActionHandler(AuthenticatedHandler):
249 self.set_status(204)
256 self.set_status(204)
250 if action == 'restart':
257 if action == 'restart':
251 new_kernel_id = km.restart_kernel(kernel_id)
258 new_kernel_id = km.restart_kernel(kernel_id)
252 ws_url = self.application.ipython_app.get_ws_url()
259 data = {'ws_url':self.ws_url,'kernel_id':new_kernel_id}
253 data = {'ws_url':ws_url,'kernel_id':new_kernel_id}
254 self.set_header('Location', '/'+new_kernel_id)
260 self.set_header('Location', '/'+new_kernel_id)
255 self.write(jsonapi.dumps(data))
261 self.write(jsonapi.dumps(data))
256 self.finish()
262 self.finish()
@@ -147,7 +147,6 aliases.update({
147 'port': 'NotebookApp.port',
147 'port': 'NotebookApp.port',
148 'keyfile': 'NotebookApp.keyfile',
148 'keyfile': 'NotebookApp.keyfile',
149 'certfile': 'NotebookApp.certfile',
149 'certfile': 'NotebookApp.certfile',
150 'ws-hostname': 'NotebookApp.ws_hostname',
151 'notebook-dir': 'NotebookManager.notebook_dir',
150 'notebook-dir': 'NotebookManager.notebook_dir',
152 })
151 })
153
152
@@ -155,7 +154,7 aliases.update({
155 # multi-kernel evironment:
154 # multi-kernel evironment:
156 aliases.pop('f', None)
155 aliases.pop('f', None)
157
156
158 notebook_aliases = [u'port', u'ip', u'keyfile', u'certfile', u'ws-hostname',
157 notebook_aliases = [u'port', u'ip', u'keyfile', u'certfile',
159 u'notebook-dir']
158 u'notebook-dir']
160
159
161 #-----------------------------------------------------------------------------
160 #-----------------------------------------------------------------------------
@@ -200,13 +199,6 class NotebookApp(BaseIPythonApplication):
200 help="The port the notebook server will listen on."
199 help="The port the notebook server will listen on."
201 )
200 )
202
201
203 ws_hostname = Unicode(LOCALHOST, config=True,
204 help="""The FQDN or IP for WebSocket connections. The default will work
205 fine when the server is listening on localhost, but this needs to
206 be set if the ip option is used. It will be used as the hostname part
207 of the WebSocket url: ws://hostname/path."""
208 )
209
210 certfile = Unicode(u'', config=True,
202 certfile = Unicode(u'', config=True,
211 help="""The full path to an SSL/TLS certificate file."""
203 help="""The full path to an SSL/TLS certificate file."""
212 )
204 )
@@ -226,14 +218,6 class NotebookApp(BaseIPythonApplication):
226 help="Whether to prevent editing/execution of notebooks."
218 help="Whether to prevent editing/execution of notebooks."
227 )
219 )
228
220
229 def get_ws_url(self):
230 """Return the WebSocket URL for this server."""
231 if self.certfile:
232 prefix = u'wss://'
233 else:
234 prefix = u'ws://'
235 return prefix + self.ws_hostname + u':' + unicode(self.port)
236
237 def parse_command_line(self, argv=None):
221 def parse_command_line(self, argv=None):
238 super(NotebookApp, self).parse_command_line(argv)
222 super(NotebookApp, self).parse_command_line(argv)
239 if argv is None:
223 if argv is None:
General Comments 0
You need to be logged in to leave comments. Login now