def get(self, args):
is_file_request = ('file' in args)
is_git_request = ('repo' in args and 'path' in args)
valid_request = xor(is_file_request, is_git_request)
if not valid_request:
self.render('404.html')
hubauth = HubAuth(options.config)
# authenticate() returns either a username as a string or a redirect
redirection = username = hubauth.authenticate(self.request)
util.logger.info("authenticate returned: {}".format(redirection))
is_redirect = (redirection.startswith('/') or
redirection.startswith('http'))
if is_redirect:
values = []
for k, v in args.items():
if not isinstance(v, str):
v = '&path='.join(v)
values.append('%s=%s' % (k, v))
util.logger.info("rendering landing page")
download_links = (util.generate_git_download_link(args)
if is_git_request
else [args['file']])
return self.render(
'landing.html',
authenticate_link=redirection,
download_links=download_links,
query='&'.join(values))
util.logger.info("rendering progress page")
# These config options are passed into the `openStatusSocket`
# JS function.
socket_args = json.dumps({
'is_development': options.config['DEBUG'],
'base_url': options.config['URL'],
'username': username,
})
self.render("progress.html", socket_args=socket_args)
评论列表
文章目录