本文整理匯總了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