本文整理汇总了Python中webinterface.PYLOAD.getWSAddress方法的典型用法代码示例。如果您正苦于以下问题:Python PYLOAD.getWSAddress方法的具体用法?Python PYLOAD.getWSAddress怎么用?Python PYLOAD.getWSAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webinterface.PYLOAD
的用法示例。
在下文中一共展示了PYLOAD.getWSAddress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def index():
# the browser should not set this, but remove in case to to avoid cached requests
if 'HTTP_IF_MODIFIED_SINCE' in request.environ:
del request.environ['HTTP_IF_MODIFIED_SINCE']
if UNAVAILALBE:
return serve_static("unavailable.html")
resp = serve_static('index.html')
# set variable depending on setup mode
setup = 'false' if SETUP is None else 'true'
ws = PYLOAD.getWSAddress() if PYLOAD else False
external = PYLOAD.getConfigValue('webUI', 'external') if PYLOAD else None
web = None
if PYLOAD:
web = PYLOAD.getConfigValue('webUI', 'port')
elif SETUP:
web = SETUP.config['webUI']['port']
# Render variables into the html page
if resp.status_code == 200:
content = resp.body.read()
resp.body = template(content, ws=ws, web=web, setup=setup, external=external, prefix=PREFIX)
resp.content_length = len(resp.body) + 1
# these page should not be cached at all
resp.headers.append("Cache-Control", "no-cache")
# they are rendered and last modified would be wrong
if "Last-Modified" in resp.headers:
del resp.headers["Last-Modified"]
return resp
示例2: pre_processor
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def pre_processor():
s = request.environ.get("beaker.session")
api = get_user_api(s)
user = None
status = None
if api is not None:
user = api.user
status = api.getServerStatus()
return {"user": user, "server": status, "url": request.url, "ws": PYLOAD.getWSAddress()}
示例3: index
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def index():
if UNAVAILALBE:
return server_static("unavailable.html")
if SETUP:
# TODO show different page
pass
f = server_static('index.html')
content = f.body.read()
f.body = template(content, ws=PYLOAD.getWSAddress(), web=PYLOAD.getConfigValue('webinterface', 'port'))
return f
示例4: pre_processor
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def pre_processor():
s = request.environ.get('beaker.session')
api = get_user_api(s)
user = None
status = None
if api is not None:
user = api.user
status = api.getServerStatus()
return {"user": user,
'server': status,
'url': request.url ,
'ws': PYLOAD.getWSAddress()}
示例5: index
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def index():
if UNAVAILALBE:
return server_static("unavailable.html")
if SETUP:
# TODO show different page
pass
resp = server_static('index.html')
# Render variables into the html page
if resp.status_code == 200:
content = resp.body.read()
resp.body = template(content, ws=PYLOAD.getWSAddress(), web=PYLOAD.getConfigValue('webinterface', 'port'))
return resp
示例6: index
# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getWSAddress [as 别名]
def index():
if UNAVAILALBE:
return serve_static("unavailable.html")
resp = serve_static('index.html')
# set variable depending on setup mode
setup = 'false' if SETUP is None else 'true'
ws = PYLOAD.getWSAddress() if PYLOAD else False
web = PYLOAD.getConfigValue('webinterface', 'port') if PYLOAD else False
# Render variables into the html page
if resp.status_code == 200:
content = resp.body.read()
resp.body = template(content, ws=ws, web=web, setup=setup)
resp.content_length = len(resp.body)
return resp