当前位置: 首页>>代码示例>>Python>>正文


Python Flak.config['SERVER_NAME']方法代码示例

本文整理汇总了Python中flak.Flak.config['SERVER_NAME']方法的典型用法代码示例。如果您正苦于以下问题:Python Flak.config['SERVER_NAME']方法的具体用法?Python Flak.config['SERVER_NAME']怎么用?Python Flak.config['SERVER_NAME']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flak.Flak的用法示例。


在下文中一共展示了Flak.config['SERVER_NAME']方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_subdomain_matching_with_ports

# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config['SERVER_NAME'] [as 别名]
def test_subdomain_matching_with_ports():
    app = Flak(__name__)
    app.config['SERVER_NAME'] = 'localhost:3000'

    @app.route('/', subdomain='<user>')
    def index(cx, user):
        return 'index for %s' % user

    c = app.test_client()
    rv = c.get('/', 'http://mitsuhiko.localhost:3000/')
    assert rv.data == b'index for mitsuhiko'
开发者ID:avdd,项目名称:flak,代码行数:13,代码来源:test_basic.py

示例2: test_basic_url_generation

# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config['SERVER_NAME'] [as 别名]
def test_basic_url_generation():
    app = Flak(__name__)
    app.config['SERVER_NAME'] = 'localhost'
    app.config['PREFERRED_URL_SCHEME'] = 'https'

    @app.route('/')
    def index(cx):
        pass

    with app.new_context() as cx:
        rv = cx.url_for('index')
        assert rv == 'https://localhost/'
开发者ID:avdd,项目名称:flak,代码行数:14,代码来源:test_context.py

示例3: test_environ_defaults_from_config

# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config['SERVER_NAME'] [as 别名]
def test_environ_defaults_from_config():
    app = Flak(__name__)
    app.config['SERVER_NAME'] = 'example.com:1234'
    app.config['APPLICATION_ROOT'] = '/foo'
    @app.route('/')
    def index(cx):
        return cx.request.url

    cx = app.test_context()
    assert cx.request.url == 'http://example.com:1234/foo/'
    with app.test_client() as c:
        rv = c.get('/')
        assert rv.data == b'http://example.com:1234/foo/'
开发者ID:avdd,项目名称:flak,代码行数:15,代码来源:test_testing.py

示例4: test_nosubdomain

# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config['SERVER_NAME'] [as 别名]
def test_nosubdomain():
    app = Flak(__name__)
    app.config['SERVER_NAME'] = 'example.com'
    @app.route('/<company_id>')
    def view(cx, company_id):
        return company_id

    with app.test_context() as cx:
        url = cx.url_for('view', company_id='xxx')

    with app.test_client() as c:
        response = c.get(url)

    assert 200 == response.status_code
    assert b'xxx' == response.data
开发者ID:avdd,项目名称:flak,代码行数:17,代码来源:test_testing.py

示例5: test_subdomain_basic_support

# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config['SERVER_NAME'] [as 别名]
def test_subdomain_basic_support():
    app = Flak(__name__)
    app.config['SERVER_NAME'] = 'localhost'

    @app.route('/')
    def normal_index(cx):
        return 'normal index'

    @app.route('/', subdomain='test')
    def test_index(cx):
        return 'test index'

    c = app.test_client()
    rv = c.get('/', 'http://localhost/')
    assert rv.data == b'normal index'

    rv = c.get('/', 'http://test.localhost/')
    assert rv.data == b'test index'
开发者ID:avdd,项目名称:flak,代码行数:20,代码来源:test_basic.py


注:本文中的flak.Flak.config['SERVER_NAME']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。