本文整理汇总了Python中bottle.static_file方法的典型用法代码示例。如果您正苦于以下问题:Python bottle.static_file方法的具体用法?Python bottle.static_file怎么用?Python bottle.static_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle
的用法示例。
在下文中一共展示了bottle.static_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _bottle_handler
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def _bottle_handler(self):
from bottle import static_file, request
@self._app.get(self._uri())
@self._app.get(self._uri(r'/'))
def index():
return self.doc_html
@self._app.get(self._uri(r'/swagger.json'))
def config_handler():
return self.get_config(request.urlparts.netloc)
@self._app.get(self._uri(r'/<filepath>'))
def java_script_file(filepath):
return static_file(filepath, root=self.static_dir)
if self._editor:
@self._app.get(self._uri('/editor'))
def editor():
return self.editor_html
示例2: send_image
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def send_image(filename):
path = os.path.join(os.path.dirname(sys.argv[0]),'./resources/files/fonts' )
return static_file(filename, root= path)
示例3: server_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_static(filename):
if filename in ("doc", "projects", "contact", "download","index"):
path = os.path.join(os.path.dirname(sys.argv[0]),'./resources/static/')
return static_file(filename+".html", root=path)
else:
return "<h2>Page Not found</h2>"
#------------------
# actions files
#------------------
示例4: server_doku
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_doku(filepath):
"""This function serves Dokuwiki files as static text files. This is
far from being great...
"""
filepath = filepath.lower().replace(':', '/')
if '.' not in os.path.basename(filepath):
filepath += '.txt'
return static_file(filepath, root=WEB_DOKU_PATH)
示例5: server_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_static(filepath):
"""Serve the static (HTML, JS, CSS, ...) content."""
return static_file(filepath, root=WEB_STATIC_PATH)
示例6: _static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def _static(path):
response = None
if 'jinja_env' in _start_args and 'jinja_templates' in _start_args:
template_prefix = _start_args['jinja_templates'] + '/'
if path.startswith(template_prefix):
n = len(template_prefix)
template = _start_args['jinja_env'].get_template(path[n:])
response = btl.HTTPResponse(template.render())
if response is None:
response = btl.static_file(path, root=root_path)
_set_response_headers(response)
return response
示例7: _get_static_file
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def _get_static_file(self, path):
return bottle.static_file(path, self._content_root)
示例8: server_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_static(filename):
return static_file(filename, root=static_dir)
示例9: serve_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def serve_static(filename):
return static_file(filename, root='./static')
示例10: server_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_static(filepath):
"""Handler for static files, used with the development server."""
root_folder = os.path.abspath(os.path.dirname(__file__))
return bottle.static_file(filepath, root=os.path.join(root_folder, 'static'))
示例11: server_static
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def server_static(filepath):
return static_file(filepath, root='static')
示例12: assets
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def assets(path):
yield static_file(path, root=settings.STATIC_PATH)
示例13: getconfig
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def getconfig(name):
user = auth(name)
log("Served config for a user")
return static_file('config.zip',
root=user.userdir,
mimetype='application/zip',
download='config.zip')
示例14: getexe
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def getexe(name):
user = auth(name)
log("Served exe for a user")
return static_file('Lokun-install.exe',
root=user.userdir,
mimetype='application/octet-stream',
download='Lokun-install.exe')
示例15: rrdgraph
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import static_file [as 别名]
def rrdgraph(name):
key_auth()
# bottle handles 404 automatically
return static_file(name + '_graph.png',
root=config.rrdroot,
mimetype='image/png')
# -----------------
# /callbacks
# -----------------