Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyterhub-ai
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Bücker
jupyterhub-ai
Commits
9e2c3de5
Commit
9e2c3de5
authored
1 year ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
changed method to find jupyterlab base url for dash app
parent
cc492b0f
No related branches found
No related tags found
2 merge requests
!6
Finalized Jupyterlab for the sprint
,
!3
changed method to find jupyterlab base url for dash app
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/app.py
+23
-2
23 additions, 2 deletions
app/app.py
with
23 additions
and
2 deletions
app/app.py
+
23
−
2
View file @
9e2c3de5
...
...
@@ -4,13 +4,25 @@ sys.path.append("/home/jovyan/")
import
argparse
import
logging
from
urllib.parse
import
urlparse
,
urljoin
from
dash
import
Dash
from
jupyter_server.serverapp
import
list_running_servers
from
layout
import
layout
from
callbacks
import
register_callbacks
logging
.
basicConfig
(
level
=
logging
.
INFO
)
# weird trick to find base_url for the jupyterlab
def
find_jupyterlab_base_url
():
servers
=
list_running_servers
()
for
server
in
servers
:
if
server
[
"
port
"
]
==
8888
:
return
server
[
'
url
'
]
return
None
# get the correct port from proxy
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -23,10 +35,19 @@ if not port:
else
:
logging
.
debug
(
f
"
Dash app running on port
{
port
}
.
"
)
base_url
=
find_jupyterlab_base_url
()
if
base_url
is
None
:
raise
ValueError
(
"
Base URL of Jupyterlab could not be detected.
"
)
logging
.
debug
(
f
"
Base URL:
{
base_url
}
"
)
proxy_base_path
=
urlparse
(
urljoin
(
base_url
+
"
/
"
,
f
"
proxy/
{
port
}
/
"
)).
path
logging
.
debug
(
f
"
Proxy base path:
{
proxy_base_path
}
"
)
# define Dash app
app
=
Dash
(
name
=
__name__
,
requests_pathname_prefix
=
"
/Dash/
"
requests_pathname_prefix
=
proxy_base_path
)
# define layout
...
...
@@ -39,6 +60,6 @@ register_callbacks(app=app)
app
.
run
(
jupyter_mode
=
"
jupyterlab
"
,
port
=
port
,
host
=
"
localhost
"
,
host
=
"
0.0.0.0
"
,
debug
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment