本文整理汇总了Python中flask.helpers.url_for方法的典型用法代码示例。如果您正苦于以下问题:Python helpers.url_for方法的具体用法?Python helpers.url_for怎么用?Python helpers.url_for使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.helpers
的用法示例。
在下文中一共展示了helpers.url_for方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_url_for_logout_view
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def _get_url_for_logout_view(self):
return url_for(self._logout_view.__name__, _external=True) if self._logout_view else None
示例2: url_for
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def url_for(self, endpoint, **values):
result = url_for(endpoint, **values)
href = Href(result)
# pass along any query parameters
# this is kind of hacky as it replaces any existing parameters
return href(request.args)
示例3: url_for_symbol
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def url_for_symbol(self, value):
if value[collector.TYPE] in [collector.TYPE_FUNCTION]:
return self.url_for("path", path=self.collector.qualified_symbol_name(value))
# file or folder
path = value.get(collector.PATH, None)
return self.url_for("path", path=path) if path else ""
示例4: dispatch_request
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def dispatch_request(self, symbol_name=None):
symbol = self.collector.symbol(symbol_name, qualified=False)
if not symbol:
abort(404)
return redirect(self.url_for("path", path=self.collector.qualified_symbol_name(symbol)))
示例5: github_authorized
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def github_authorized(oauth_token):
if oauth_token is None:
flash("Authorization failed.")
return redirect(url_for('index'))
session['oauth_token'] = oauth_token
me = github.get('user')
user_id = me['login']
# is user exist
user = User.query.get(user_id)
if user is None:
# not exist, add
user = User(id=user_id)
# update github user information
user.last_login = DateUtil.now_datetime()
user.name = me.get('name', user_id)
user.location = me.get('location', '')
user.avatar = me.get('avatar_url', '')
user.save()
RequestUtil.login_user(user.dict())
return redirect(url_for('index'))
示例6: logout
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def logout():
RequestUtil.logout()
return redirect(url_for('index'))
示例7: init_oidc_provider
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def init_oidc_provider(app):
with app.app_context():
issuer = url_for('oidc_provider.index')[:-1]
authentication_endpoint = url_for('oidc_provider.authentication_endpoint')
jwks_uri = url_for('oidc_provider.jwks_uri')
token_endpoint = url_for('oidc_provider.token_endpoint')
userinfo_endpoint = url_for('oidc_provider.userinfo_endpoint')
registration_endpoint = url_for('oidc_provider.registration_endpoint')
end_session_endpoint = url_for('oidc_provider.end_session_endpoint')
configuration_information = {
'issuer': issuer,
'authorization_endpoint': authentication_endpoint,
'jwks_uri': jwks_uri,
'token_endpoint': token_endpoint,
'userinfo_endpoint': userinfo_endpoint,
'registration_endpoint': registration_endpoint,
'end_session_endpoint': end_session_endpoint,
'scopes_supported': ['openid', 'profile'],
'response_types_supported': ['code', 'code id_token', 'code token', 'code id_token token'], # code and hybrid
'response_modes_supported': ['query', 'fragment'],
'grant_types_supported': ['authorization_code', 'implicit'],
'subject_types_supported': ['pairwise'],
'token_endpoint_auth_methods_supported': ['client_secret_basic'],
'claims_parameter_supported': True
}
userinfo_db = Userinfo(app.users)
signing_key = RSAKey(key=rsa_load('signing_key.pem'), alg='RS256')
provider = Provider(signing_key, configuration_information,
AuthorizationState(HashBasedSubjectIdentifierFactory(app.config['SUBJECT_ID_HASH_SALT'])),
{}, userinfo_db)
return provider
示例8: raw_svgs
# 需要导入模块: from flask import helpers [as 别名]
# 或者: from flask.helpers import url_for [as 别名]
def raw_svgs():
chart = pygal.Line(legend_at_bottom=True, legend_box_size=18)
# =======================================
# Declare the location of svg.jquery.js and pygal-tooltips.js in server side.
# =======================================
# It must be declare in server side, not html file
# if not declare in server, by default it will load the two js files located in http://kozea.github.com/pygal.js. And it will slow down the page loading
# 1, It works, load local js files
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]
# 2.a, It Works, but it is ugly because it use local absolute http url
# chart.js =['http://127.0.0.1:5000/static/js/svg.jquery.js',
# 'http://127.0.0.1:5000/static/js/pygal-tooltips.js']
# 2.b, works, use local CDN absolute http url
# chart.js =['http://another_server/pygal-tooltips.js',
# 'http://another_server/svg.jquery.js']
# 3, Does not work, error raised at visiting, IOError: [Errno 2] No such file
# chart.js = [url_for('static', filename='js/svg.jquery.js'),
# url_for('static', filename='js/pygal-tooltips.js')]
# disable xml root node
chart.disable_xml_declaration = True
chart.title = 'Browser usage evolution (in %)'
chart.width = 2000
chart.height = 2000
chart.x_labels = map(str, range(2002, 2013))
chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])
svg_xml = chart.render()
svg_xml = '<svg style="width:2000px" ' + svg_xml[4:]
svg_xml1 = svg_xml[:100]
response = make_response(render_template('test_svg.html', title=svg_xml1, svg_xml=svg_xml))
# response.headers['Content-Type']='image/svg+xml' 不能设置Content-Type为svg模式
return response