mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Fix various review comments
This commit is contained in:
parent
b5a6cb7da1
commit
6f48b58b18
@ -277,7 +277,7 @@ class FileContentsManager(ContentsManager):
|
||||
Whether to include the contents in the reply
|
||||
type_ : str, optional
|
||||
The requested type - 'file', 'notebook', or 'directory'.
|
||||
Will raise HTTPError 406 if the content doesn't match.
|
||||
Will raise HTTPError 400 if the content doesn't match.
|
||||
format : str, optional
|
||||
The requested format for file contents. 'text' or 'base64'.
|
||||
Ignored if this returns a notebook or directory model.
|
||||
|
@ -35,7 +35,7 @@ class API(object):
|
||||
def __init__(self, base_url):
|
||||
self.base_url = base_url
|
||||
|
||||
def _req(self, verb, path, body=None):
|
||||
def _req(self, verb, path, body=None, params=None):
|
||||
response = requests.request(verb,
|
||||
url_path_join(self.base_url, 'api/contents', path),
|
||||
data=body,
|
||||
@ -47,14 +47,12 @@ class API(object):
|
||||
return self._req('GET', path)
|
||||
|
||||
def read(self, path, type_=None, format=None):
|
||||
query = []
|
||||
params = {}
|
||||
if type_ is not None:
|
||||
query.append('type=' + type_)
|
||||
params['type'] = type_
|
||||
if format is not None:
|
||||
query.append('format=' + format)
|
||||
if query:
|
||||
path += '?' + '&'.join(query)
|
||||
return self._req('GET', path)
|
||||
params['format'] = format
|
||||
return self._req('GET', path, params=params)
|
||||
|
||||
def create_untitled(self, path='/', ext='.ipynb'):
|
||||
body = None
|
||||
|
@ -87,10 +87,10 @@ define([
|
||||
error : this.create_basic_error_handler(options.error)
|
||||
};
|
||||
var url = this.api_url(path);
|
||||
if (options.type) {
|
||||
url += '?type=' + options.type;
|
||||
}
|
||||
$.ajax(url, settings);
|
||||
params = {};
|
||||
if (options.type) { params.type = options.type; }
|
||||
if (options.format) { params.format = options.format; }
|
||||
$.ajax(url + '?' + $.param(params), settings);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user