Skip to content

Commit

Permalink
Support a lot more HTTP methods
Browse files Browse the repository at this point in the history
I don't think there's any explicit reason for us to whitelist
methods
  • Loading branch information
yuvipanda committed Oct 31, 2017
1 parent 8b872e9 commit a950ce6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# nbserverproxy
Jupyter notebook server extension to proxy web services. This enables users to reach arbitrary web services running within their spawned Jupyter server and is probably most appropriate for services which can't readily be converted into extensions. GET and POST are supported.
Jupyter notebook server extension to proxy web services. This enables users to reach arbitrary web services running within their spawned Jupyter server and is probably most appropriate for services which can't readily be converted into extensions.

## Example
A user starts a web service via `New > Terminal`:
Expand Down
17 changes: 16 additions & 1 deletion nbserverproxy/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class LocalProxyHandler(IPythonHandler):
SUPPORTED_METHODS = ['GET', 'POST']
proxy_uri = "http://localhost"

@web.authenticated
Expand Down Expand Up @@ -62,12 +61,28 @@ def proxy(self, port, proxied_path):
if response.body:
self.write(response.body)

# support all the methods that torando does by default!
def get(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def post(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def put(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def delete(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def head(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def patch(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def options(self, port, proxy_path=''):
return self.proxy(port, proxy_path)

def check_xsrf_cookie(self):
'''
http://www.tornadoweb.org/en/stable/guide/security.html
Expand Down

0 comments on commit a950ce6

Please sign in to comment.