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

Fix default_url redirect with default 'main' handler #72

Merged
merged 1 commit into from
Aug 5, 2019
Merged
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
1 change: 0 additions & 1 deletion jupyter_server/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,6 @@ def get(self):

default_handlers = [
(r".*/", TrailingSlashHandler),
(r"/", MainHandler),
(r"api", APIVersionHandler),
(r'/(robots\.txt|favicon\.ico)', web.StaticFileHandler),
(r'/metrics', PrometheusMetricsHandler)
Expand Down
21 changes: 13 additions & 8 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
except NameError:
raw_input = input

from .base.handlers import Template404, RedirectWithParams
from .base.handlers import MainHandler, RedirectWithParams, Template404
from .log import log_request
from .services.kernels.kernelmanager import MappingKernelManager
from .services.config import ConfigManager
Expand Down Expand Up @@ -304,13 +304,18 @@ def init_handlers(self, settings):
)
# register base handlers last
handlers.extend(load_handlers('jupyter_server.base.handlers'))
# set the URL that will be redirected from `/`
handlers.append(
(r'/?', RedirectWithParams, {
'url' : settings['default_url'],
'permanent': False, # want 302, not 301
})
)

if settings['default_url'] != '/':
# set the URL that will be redirected from `/`
handlers.append(
(r'/?', RedirectWithParams, {
'url' : settings['default_url'],
'permanent': False, # want 302, not 301
})
)
else:
handlers.append(
(r"/", MainHandler))

# prepend base_url onto the patterns that we match
new_handlers = []
Expand Down