Python flask.request.script_root() Examples
The following are 5
code examples of flask.request.script_root().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask.request
, or try the search function
.
Example #1
Source File: user_manager__views.py From Flask-User with MIT License | 6 votes |
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))
Example #2
Source File: blob.py From quay with Apache License 2.0 | 5 votes |
def _current_request_url(): return "{0}{1}{2}".format(get_app_url(), request.script_root, request.path)
Example #3
Source File: userauth.py From confidant with Apache License 2.0 | 5 votes |
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))
Example #4
Source File: base.py From PowerDNS-Admin with MIT License | 5 votes |
def handle_unauthorized_access(e): session['next'] = request.script_root + request.path return redirect(url_for('index.login'))
Example #5
Source File: log.py From scrapydweb with GNU General Public License v3.0 | 4 votes |
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