python类static_file()的实例源码

user_data.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def download(filepath):
    root.authorized()
    return static_file(filepath, root='download', download=filepath)
handler.py 文件源码 项目:icfpc2016-judge 作者: icfpc2016 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def static_handler(path):
    return bottle.static_file(
        path,
        root=os.path.join(os.path.dirname(__file__), '..', 'static'))
main.py 文件源码 项目:indiwebmanager 作者: knro 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def callback(path):
    """Serve static files"""
    return static_file(path, root=views_path)
main.py 文件源码 项目:indiwebmanager 作者: knro 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def get_favicon():
    """Serve favicon"""
    return static_file('favicon.ico', root=views_path)
web_server.py 文件源码 项目:honeyd-python 作者: sookyp 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def css(filepath):
    return static_file(filepath, root='honeyd/utilities/http/css/')

# main page
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def default_handler():
    return bottle.static_file('app.html', root=os.path.join(conf['rootdir'], 'frontend') )
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def static_bin_handler(file):
    return bottle.static_file(file, root=os.path.join(conf['rootdir'], 'frontend'))
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def static_css_handler(path):
    return bottle.static_file(path, root=os.path.join(conf['rootdir'], 'frontend', 'css'))
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def static_font_handler(path):
    return bottle.static_file(path, root=os.path.join(conf['rootdir'], 'frontend', 'fonts'))
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def static_js_handler(path):
    return bottle.static_file(path, root=os.path.join(conf['rootdir'], 'frontend', 'js'))
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def favicon_handler():
    return bottle.static_file('favicon.ico', root=os.path.join(conf['rootdir'], 'frontend', 'img'))
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def download(filename, dlname):
    print "requesting: " + filename
    return bottle.static_file(filename, root=tempfile.gettempdir(), download=dlname)



### LOW-LEVEL
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get(jobname='woot'):
    """Get a queue job in .dba format."""
    base, name = os.path.split(_get_path(jobname))
    return bottle.static_file(name, root=base, mimetype='application/json')
web.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_library(jobname):
    """Get a library job in .dba format."""
    base, name = os.path.split(_get_path(jobname, library=True))
    return bottle.static_file(name, root=base, mimetype='application/json')
Api.py 文件源码 项目:experiment-manager 作者: softfire-eu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def server_static(filename):
    """ route to the css and static files"""
    if ".." in filename:
        return HTTPError(status=403)
    return bottle.static_file(filename, root='%s/static' % get_config('api', 'view-path', '/etc/softfire/views'))


#########
# Utils #
#########
server.py 文件源码 项目:Monitoring 作者: Skydes 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def server_static(path):
    return bottle.static_file(path, root="./")
server.py 文件源码 项目:Monitoring 作者: Skydes 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def server_captures(path):
    try:
        return bottle.static_file(path, root="./temp")
    except OSError as err:
        logging.error("Error accessing static file: {message}".format(message=err.strerror))
        return None
example.py 文件源码 项目:movies-python-py2neo-3.0 作者: neo4j-examples 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_index():
    return static_file("index.html", root="static")
pyload_app.py 文件源码 项目:download-manager 作者: thispc 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def js_dynamic(path):
    response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
                                                time.gmtime(time.time() + 60 * 60 * 24 * 2))
    response.headers['Cache-control'] = "public"
    response.headers['Content-Type'] = "text/javascript; charset=UTF-8"

    try:
        # static files are not rendered
        if "static" not in path and "mootools" not in path:
            t = env.get_template("js/%s" % path)
            return t.render()
        else:
            return static_file(path, root=join(PROJECT_DIR, "media", "js"))
    except:
        return HTTPError(404, "Not Found")
pyload_app.py 文件源码 项目:download-manager 作者: thispc 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def server_static(path):
    response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
                                                time.gmtime(time.time() + 60 * 60 * 24 * 7))
    response.headers['Cache-control'] = "public"
    return static_file(path, root=join(PROJECT_DIR, "media"))


问题


面经


文章

微信
公众号

扫码关注公众号