Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions binderhub/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,22 @@ async def launch(self, kube, provider):
username = launcher.unique_name_from_repo(self.repo_url)
server_name = ''
try:
# get file/url path, it will be passed to user_options
# this is useful when one wants to re-generate same launch url
path = self.get_argument('filepath', '').lstrip('/')
path_type = "file" if path else ""
if not path:
path = self.get_argument('urlpath', '').lstrip('/')
path_type = "url" if path else ""
app_log.info("path: %s", path)
app_log.info("path_type: %s", path_type)
extra_args = {
'binder_ref_url': self.ref_url,
'binder_launch_host': self.binder_launch_host,
'binder_request': self.binder_request,
'binder_persistent_request': self.binder_persistent_request,
'path_type': path_type,
'path': path,
}
server_info = await launcher.launch(image=self.image_name,
username=username,
Expand Down
8 changes: 6 additions & 2 deletions binderhub/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,9 @@ async def launch(self, image, username, server_name='', repo_url='', extra_args=
format(_server_name, username, e, body))
raise web.HTTPError(500, "Failed to launch image %s" % image)

data['url'] = self.hub_url + 'user/%s/%s' % (username, server_name)
return data
# return back only what is need to launch the user server
launch_data = {
"url": self.hub_url + 'user/%s/%s' % (username, server_name),
"token": data["token"],
}
return launch_data
2 changes: 1 addition & 1 deletion binderhub/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function build(providerSpec, log, path, pathType) {

$('.on-build').removeClass('hidden');

var image = new BinderImage(providerSpec);
var image = new BinderImage(providerSpec, path, pathType);

image.onStateChange('*', function(oldState, newState, data) {
if (data.message !== undefined) {
Expand Down
8 changes: 7 additions & 1 deletion binderhub/static/js/src/image.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
var BASE_URL = $("#base-url").data().url;

export default function BinderImage(providerSpec) {
export default function BinderImage(providerSpec, path, pathType) {
this.providerSpec = providerSpec;
this.path = path;
this.pathType = pathType;
this.callbacks = {};
this.state = null;
}

BinderImage.prototype.fetch = function() {
var apiUrl = BASE_URL + "build/" + this.providerSpec;
if (this.path && this.path.length > 0) {
apiUrl = apiUrl + '?' + this.pathType + 'path=' + encodeURIComponent(this.path);
}
console.log(apiUrl);
this.eventSource = new EventSource(apiUrl);
var that = this;
this.eventSource.onerror = function(err) {
Expand Down