Skip to content

Commit 89aac05

Browse files
committed
Add preflight and delete option in sessions
1 parent 7061200 commit 89aac05

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

kernel_gateway/services/sessions/handlers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ def get(self):
2727
else:
2828
super(SessionRootHandler, self).get()
2929

30+
class SessionHandler(TokenAuthorizationMixin,
31+
CORSMixin,
32+
JSONErrorsMixin,
33+
notebook_handlers.SessionHandler):
34+
"""Extends the notebook session handler with token auth, CORS, and
35+
JSON errors.
36+
"""
37+
def set_default_headers(self):
38+
self.set_header('Content-Type', 'application/json')
39+
self.set_header('Access-Control-Allow-Origin', '*')
40+
self.set_header('Access-Control-Allow-Headers', 'content-type')
41+
self.set_header('Access-Control-Allow-Methods', 'DELETE')
42+
43+
def options(self, **kwargs):
44+
"""Method for properly handling CORS pre-flight"""
45+
self.finish()
46+
3047
default_handlers = []
3148
for path, cls in notebook_handlers.default_handlers:
3249
if cls.__name__ in globals():

0 commit comments

Comments
 (0)