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 404 after jupyterhub 1.0.0 #39

Merged
merged 1 commit into from
May 10, 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
9 changes: 7 additions & 2 deletions cylc_singleuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

from graphene_tornado.schema import schema
from graphene_tornado.tornado_graphql_handler import TornadoGraphQLHandler
from jupyterhub.services.auth import HubOAuthCallbackHandler
from jupyterhub.utils import url_path_join
from tornado import web, ioloop

from handlers import *
from jupyterhub.services.auth import HubOAuthCallbackHandler
from jupyterhub.utils import url_path_join


class MyApplication(web.Application):
Expand Down Expand Up @@ -83,6 +83,11 @@ def _make_app(self):
TornadoGraphQLHandler, dict(graphiql=True, schema=schema, batch=True)),
(url_path_join(self._jupyter_hub_service_prefix, '/graphql/graphiql'),
TornadoGraphQLHandler, dict(graphiql=True, schema=schema)),

# since jupyterhub 1.0.0, the "My Server link the hub page removed the last
# slash from the URL. This handler is based on the handler with the same name
# in jupyterhub 1.0.0, and adds back the last `/` to every URL in the app.
(r".*", AddSlashHandler)
],
# FIXME: decide (and document) whether cookies will be permanent after server restart.
cookie_secret="cylc-secret-cookie"
Expand Down
23 changes: 19 additions & 4 deletions handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import json
import re
import os
import re
from subprocess import Popen, PIPE
from typing import List, Union
from urllib.parse import urlparse
from urllib.parse import urlunparse

from jupyterhub.services.auth import HubOAuthenticated
from tornado import web
from typing import List, Union

from jupyterhub import __version__ as jupyterhub_version
from jupyterhub.services.auth import HubOAuthenticated


class BaseHandler(web.RequestHandler):
Expand Down Expand Up @@ -101,4 +103,17 @@ def get(self):
self.write(json.dumps(suites))


__all__ = ["MainHandler", "UserProfileHandler", "CylcScanHandler"]
class AddSlashHandler(web.RequestHandler):

def get(self, *args):
src = urlparse(self.request.uri)
dest = src._replace(path=src.path + '/')
self.redirect(urlunparse(dest))


__all__ = [
"MainHandler",
"UserProfileHandler",
"CylcScanHandler",
"AddSlashHandler"
]