Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preflight and delete option in sessions handler #363

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions kernel_gateway/services/sessions/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ def get(self):
else:
super(SessionRootHandler, self).get()

class SessionHandler(TokenAuthorizationMixin,
CORSMixin,
JSONErrorsMixin,
notebook_handlers.SessionHandler):
"""Extends the notebook session handler with token auth, CORS, and
JSON errors.
"""
def set_default_headers(self):
self.set_header('Content-Type', 'application/json')
self.set_header('Access-Control-Allow-Origin', '*')
blink1073 marked this conversation as resolved.
Show resolved Hide resolved
self.set_header('Access-Control-Allow-Headers', 'content-type')
self.set_header('Access-Control-Allow-Methods', 'DELETE')

def options(self, **kwargs):
"""Method for properly handling CORS pre-flight"""
self.finish()

default_handlers = []
for path, cls in notebook_handlers.default_handlers:
if cls.__name__ in globals():
Expand Down