本文整理汇总了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'
示例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/'
示例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/'
示例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
示例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'