當前位置: 首頁>>代碼示例>>Python>>正文


Python helpers.url_for方法代碼示例

本文整理匯總了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 
開發者ID:zamzterz,項目名稱:Flask-pyoidc,代碼行數:4,代碼來源:flask_pyoidc.py

示例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) 
開發者ID:HBehrens,項目名稱:puncover,代碼行數:8,代碼來源:renderers.py

示例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 "" 
開發者ID:HBehrens,項目名稱:puncover,代碼行數:9,代碼來源:renderers.py

示例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))) 
開發者ID:HBehrens,項目名稱:puncover,代碼行數:8,代碼來源:renderers.py

示例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')) 
開發者ID:NetEaseGame,項目名稱:git-webhook,代碼行數:30,代碼來源:common.py

示例6: logout

# 需要導入模塊: from flask import helpers [as 別名]
# 或者: from flask.helpers import url_for [as 別名]
def logout():
    RequestUtil.logout()
    return redirect(url_for('index')) 
開發者ID:NetEaseGame,項目名稱:git-webhook,代碼行數:5,代碼來源:common.py

示例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 
開發者ID:IdentityPython,項目名稱:pyop,代碼行數:36,代碼來源:app.py

示例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 
開發者ID:harryliu,項目名稱:edwin,代碼行數:45,代碼來源:views.py


注:本文中的flask.helpers.url_for方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。