Show More
@@ -22,6 +22,7 b' from tornado import web' | |||
|
22 | 22 | from zmq.utils import jsonapi |
|
23 | 23 | |
|
24 | 24 | from IPython.utils.jsonutil import date_default |
|
25 | from IPython.html.utils import url_path_join | |
|
25 | 26 | |
|
26 | 27 | from ...base.handlers import IPythonHandler, json_errors |
|
27 | 28 | from ...base.zmqhandlers import AuthenticatedZMQStreamHandler |
@@ -45,7 +46,8 b' class MainKernelHandler(IPythonHandler):' | |||
|
45 | 46 | km = self.kernel_manager |
|
46 | 47 | kernel_id = km.start_kernel() |
|
47 | 48 | model = km.kernel_model(kernel_id, self.ws_url) |
|
48 | self.set_header('Location', '{0}api/kernels/{1}'.format(self.base_kernel_url, kernel_id)) | |
|
49 | location = url_path_join(self.base_kernel_url, 'api', 'kernels', kernel_id) | |
|
50 | self.set_header('Location', location) | |
|
49 | 51 | self.set_status(201) |
|
50 | 52 | self.finish(jsonapi.dumps(model)) |
|
51 | 53 |
@@ -19,8 +19,10 b' Authors:' | |||
|
19 | 19 | import json |
|
20 | 20 | |
|
21 | 21 | from tornado import web |
|
22 | from IPython.utils.jsonutil import date_default | |
|
22 | ||
|
23 | 23 | from ...base.handlers import IPythonHandler, json_errors |
|
24 | from IPython.utils.jsonutil import date_default | |
|
25 | from IPython.html.utils import url_path_join | |
|
24 | 26 | |
|
25 | 27 | #----------------------------------------------------------------------------- |
|
26 | 28 | # Session web service handlers |
@@ -62,7 +64,8 b' class SessionRootHandler(IPythonHandler):' | |||
|
62 | 64 | else: |
|
63 | 65 | kernel_id = km.start_kernel(cwd=nbm.notebook_dir) |
|
64 | 66 | model = sm.create_session(name=name, path=path, kernel_id=kernel_id, ws_url=self.ws_url) |
|
65 | self.set_header('Location', '{0}/api/sessions/{1}'.format(self.base_project_url, model['id'])) | |
|
67 | location = url_path_join(self.base_kernel_url, 'api', 'sessions', model['id']) | |
|
68 | self.set_header('Location', location) | |
|
66 | 69 | self.set_status(201) |
|
67 | 70 | self.finish(json.dumps(model, default=date_default)) |
|
68 | 71 |
@@ -74,6 +74,7 b' class SessionAPITest(NotebookTestBase):' | |||
|
74 | 74 | self.assertIn('id', newsession) |
|
75 | 75 | self.assertEqual(newsession['notebook']['name'], 'nb1.ipynb') |
|
76 | 76 | self.assertEqual(newsession['notebook']['path'], 'foo') |
|
77 | self.assertEqual(resp.headers['Location'], '/api/sessions/{0}'.format(newsession['id'])) | |
|
77 | 78 | |
|
78 | 79 | sessions = self.sess_api.list().json() |
|
79 | 80 | self.assertEqual(sessions, [newsession]) |
General Comments 0
You need to be logged in to leave comments.
Login now