本文整理汇总了Python中flask.request.script_root方法的典型用法代码示例。如果您正苦于以下问题:Python request.script_root方法的具体用法?Python request.script_root怎么用?Python request.script_root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.request
的用法示例。
在下文中一共展示了request.script_root方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unauthorized_view
# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import script_root [as 别名]
def unauthorized_view(self):
""" Prepare a Flash message and redirect to USER_UNAUTHORIZED_ENDPOINT"""
# Prepare Flash message
url = request.script_root + request.path
flash(_("You do not have permission to access '%(url)s'.", url=url), 'error')
# Redirect to USER_UNAUTHORIZED_ENDPOINT
return redirect(self._endpoint_url(self.USER_UNAUTHORIZED_ENDPOINT))
# def unconfirmed_email_view(self):
# """ Prepare a Flash message and redirect to USER_UNCONFIRMED_ENDPOINT"""
# # Prepare Flash message
# url = request.script_root + request.path
# flash(_("You must confirm your email to access '%(url)s'.", url=url), 'error')
#
# # Redirect to USER_UNCONFIRMED_EMAIL_ENDPOINT
# return redirect(self._endpoint_url(self.USER_UNCONFIRMED_EMAIL_ENDPOINT))
示例2: log_in
# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import script_root [as 别名]
def log_in(self):
"""
SAML log-in redirect.
This method initiates the SAML authentication process by directing the
browser to forward along an AuthNRequest to the IdP.
A separate method handles the post-authentication callback, which will
hit /v1/saml/consume, processed by consume_saml_assertion().
"""
self_page = request.script_root + request.path
return flask.redirect(self.login_redirect_url(return_to=self_page))
示例3: _current_request_url
# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import script_root [as 别名]
def _current_request_url():
return "{0}{1}{2}".format(get_app_url(), request.script_root, request.path)
示例4: handle_unauthorized_access
# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import script_root [as 别名]
def handle_unauthorized_access(e):
session['next'] = request.script_root + request.path
return redirect(url_for('index.login'))
示例5: update_kwargs
# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import script_root [as 别名]
def update_kwargs(self):
if self.utf8_realtime:
self.kwargs['text'] = self.text
self.kwargs['last_update_timestamp'] = time.time()
if self.job_finished or self.job_key in job_finished_key_dict[self.node]:
self.kwargs['url_refresh'] = ''
else:
self.kwargs['url_refresh'] = 'javascript:location.reload(true);'
else:
# Parsed data comes from json.loads, for compatibility with Python 2,
# use str(time_) to avoid [u'2019-01-01 00:00:01', 0, 0, 0, 0] in JavaScript.
for d in self.stats['datas']:
d[0] = str(d[0])
# For sorted orders in stats.html with Python 2
for k in ['crawler_stats', 'crawler_engine']:
if self.stats[k]:
self.stats[k] = self.get_ordered_dict(self.stats[k])
if self.BACKUP_STATS_JSON_FILE:
self.backup_stats()
self.kwargs.update(self.stats)
if (self.kwargs['finish_reason'] == self.NA
and not self.job_finished
and self.job_key not in job_finished_key_dict[self.node]):
# http://flask.pocoo.org/docs/1.0/api/#flask.Request.url_root
# _query_string = '?ui=mobile'
# self.url_refresh = request.script_root + request.path + _query_string
self.kwargs['url_refresh'] = 'javascript:location.reload(true);'
if self.kwargs['url_refresh']:
if self.stats_logparser and not self.logparser_valid:
self.kwargs['url_jump'] = ''
else:
self.kwargs['url_jump'] = url_for('log', node=self.node, opt='stats', project=self.project,
spider=self.spider, job=self.job, with_ext=self.with_ext,
ui=self.UI, realtime='True' if self.stats_logparser else None)
# Stats link of 'a.json' from the Logs page should hide these links
if self.with_ext and self.job.endswith('.json'):
self.kwargs['url_source'] = ''
self.kwargs['url_opt_opposite'] = ''
self.kwargs['url_refresh'] = ''
self.kwargs['url_jump'] = ''
else:
if self.SCRAPYD_SERVER_PUBLIC_URL:
self.kwargs['url_source'] = re.sub(r'^http.*?/logs/', self.SCRAPYD_SERVER_PUBLIC_URL + '/logs/',
self.url)
else:
self.kwargs['url_source'] = self.url
self.kwargs['url_opt_opposite'] = url_for('log', node=self.node,
opt='utf8' if self.opt == 'stats' else 'stats',
project=self.project, spider=self.spider, job=self.job,
job_finished=self.job_finished, with_ext=self.with_ext,
ui=self.UI)
# TODO: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-x-email-support