mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #54 from jaredly/fix-api-cors
allow OPTIONS requests for api endpoints (to enable CORS)
This commit is contained in:
commit
c5fe672d65
@ -48,7 +48,7 @@ class MainKernelHandler(IPythonHandler):
|
||||
|
||||
class KernelHandler(IPythonHandler):
|
||||
|
||||
SUPPORTED_METHODS = ('DELETE', 'GET')
|
||||
SUPPORTED_METHODS = ('DELETE', 'GET', 'OPTIONS')
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
@ -66,6 +66,12 @@ class KernelHandler(IPythonHandler):
|
||||
self.set_status(204)
|
||||
self.finish()
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
def options(self, kernel_id):
|
||||
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
|
||||
self.finish()
|
||||
|
||||
|
||||
class KernelActionHandler(IPythonHandler):
|
||||
|
||||
@ -83,6 +89,12 @@ class KernelActionHandler(IPythonHandler):
|
||||
self.write(json.dumps(model))
|
||||
self.finish()
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
def options(self, kernel_id, action):
|
||||
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
|
||||
self.finish()
|
||||
|
||||
|
||||
class ZMQChannelsHandler(AuthenticatedZMQStreamHandler):
|
||||
|
||||
|
@ -41,7 +41,7 @@ def kernelspec_model(handler, name):
|
||||
return d
|
||||
|
||||
class MainKernelSpecHandler(IPythonHandler):
|
||||
SUPPORTED_METHODS = ('GET',)
|
||||
SUPPORTED_METHODS = ('GET', 'OPTIONS')
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
@ -61,6 +61,11 @@ class MainKernelSpecHandler(IPythonHandler):
|
||||
self.set_header("Content-Type", 'application/json')
|
||||
self.finish(json.dumps(model))
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
def options(self):
|
||||
self.finish()
|
||||
|
||||
|
||||
class KernelSpecHandler(IPythonHandler):
|
||||
SUPPORTED_METHODS = ('GET',)
|
||||
|
@ -65,6 +65,12 @@ class SessionRootHandler(IPythonHandler):
|
||||
self.set_status(201)
|
||||
self.finish(json.dumps(model, default=date_default))
|
||||
|
||||
@web.authenticated
|
||||
@json_errors
|
||||
def options(self):
|
||||
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
|
||||
self.finish()
|
||||
|
||||
class SessionHandler(IPythonHandler):
|
||||
|
||||
SUPPORTED_METHODS = ('GET', 'PATCH', 'DELETE')
|
||||
|
Loading…
Reference in New Issue
Block a user