本文整理匯總了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
# -----------------