当前位置: 首页>>代码示例>>Python>>正文


Python flask.send_from_directory方法代码示例

本文整理汇总了Python中flask.send_from_directory方法的典型用法代码示例。如果您正苦于以下问题:Python flask.send_from_directory方法的具体用法?Python flask.send_from_directory怎么用?Python flask.send_from_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask的用法示例。


在下文中一共展示了flask.send_from_directory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_download_file

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def do_download_file(book, book_format, client, data, headers):
    if config.config_use_google_drive:
        startTime = time.time()
        df = gd.getFileFromEbooksFolder(book.path, data.name + "." + book_format)
        log.debug('%s', time.time() - startTime)
        if df:
            return gd.do_gdrive_download(df, headers)
        else:
            abort(404)
    else:
        filename = os.path.join(config.config_calibre_dir, book.path)
        if not os.path.isfile(os.path.join(filename, data.name + "." + book_format)):
            # ToDo: improve error handling
            log.error('File not found: %s', os.path.join(filename, data.name + "." + book_format))

        if client == "kobo" and book_format == "kepub":
            headers["Content-Disposition"] = headers["Content-Disposition"].replace(".kepub", ".kepub.epub")

        response = make_response(send_from_directory(filename, data.name + "." + book_format))
        # ToDo Check headers parameter
        for element in headers:
            response.headers[element[0]] = element[1]
        return response

################################## 
开发者ID:janeczku,项目名称:calibre-web,代码行数:27,代码来源:helper.py

示例2: send_data

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_data(path):
    """Send a given data file to qutebrowser.

    If a directory is requested, its index.html is sent.
    """
    if hasattr(sys, 'frozen'):
        basedir = os.path.realpath(os.path.dirname(sys.executable))
        data_dir = os.path.join(basedir, 'end2end', 'data')
    else:
        basedir = os.path.join(os.path.realpath(os.path.dirname(__file__)),
                               '..')
        data_dir = os.path.join(basedir, 'data')
    print(basedir)
    if os.path.isdir(os.path.join(data_dir, path)):
        path += '/index.html'
    return flask.send_from_directory(data_dir, path) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:webserver_sub.py

示例3: configure_static_route

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def configure_static_route(app):
    # Note (dmsimard)
    # /static/ is provided from in-tree bundled files and libraries.
    # /static/packaged/ is routed to serve packaged (i.e, XStatic) libraries.
    #
    # The reason why this isn't defined as a proper view by itself is due to
    # a limitation in flask-frozen. Blueprint'd views methods are like so:
    # "<view>.<method>. The URL generator of flask-frozen is a method decorator
    # that expects the method name as the function and, obviously, you can't
    # really have dots in functions.
    # By having the route configured at the root of the application, there's no
    # dots and we can decorate "serve_static_packaged" instead of, say,
    # "static.serve_packaged".

    @app.route('/static/packaged/<module>/<path:filename>')
    def serve_static_packaged(module, filename):
        xstatic = current_app.config['XSTATIC']

        if module in xstatic:
            return send_from_directory(xstatic[module], filename)
        else:
            abort(404) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:24,代码来源:webapp.py

示例4: _add_url_rules

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def _add_url_rules(self, app):

        @app.route('/static/css/<path:filename>')
        def route_css_files(filename):
            directory = pth.join(disk.root_dir, 'static/css')
            return flask.send_from_directory(directory, filename)

        @app.route('/build/<path:filename>')
        def route_build_files(filename):
            directory = pth.join(disk.root_dir, 'build')
            return flask.send_from_directory(directory, filename)

        @app.route('/')
        def render():
            return self.render()

        @app.route('/', methods=['POST'])
        def update_styles():
            stylesheet = request.form['input-stylesheet']
            self._input_status = save_scratch_plots(stylesheet)
            self._input_stylesheet = stylesheet
            return self.render() 
开发者ID:tonysyu,项目名称:matplotlib-style-gallery,代码行数:24,代码来源:app.py

示例5: send_favicon

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_favicon():
    return send_from_directory(STATIC, 'favicon.ico') 
开发者ID:chubin,项目名称:rate.sx,代码行数:4,代码来源:srv.py

示例6: StaticRequests

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def StaticRequests():
    reqfile = request.path[1:]
    sp = os.path.join(app.root_path,cfg.staticdir) 
    mimetype=None
    if reqfile == 'image.svg':
        mimetype = 'image/svg+xml'
    return send_from_directory(sp,reqfile,mimetype=mimetype) 
开发者ID:CboeSecurity,项目名称:password_pwncheck,代码行数:9,代码来源:password-pwncheck.py

示例7: send_static

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_static(path):
    return send_from_directory(STATIC, path) 
开发者ID:chubin,项目名称:rate.sx,代码行数:4,代码来源:srv.py

示例8: send_malformed

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_malformed():
    return send_from_directory(STATIC, 'malformed-response.html') 
开发者ID:chubin,项目名称:rate.sx,代码行数:4,代码来源:srv.py

示例9: send_static

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_static(path):
     print("path: {}".format(path))
     try:
         return flask.send_from_directory('static', path)
     except Exception as e:
        print("path: {}".format(path))
        with open('exception', 'w') as f:
            f.write(str(type(e))+' '+str(e))
        return 
开发者ID:dissemin,项目名称:oabot,代码行数:11,代码来源:app.py

示例10: send_edits

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def send_edits(path):
    return flask.send_from_directory('edits', path) 
开发者ID:dissemin,项目名称:oabot,代码行数:4,代码来源:app.py

示例11: robots

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def robots():
    """Robots handler."""
    return send_from_directory(app.static_folder, request.path[1:]) 
开发者ID:smallwat3r,项目名称:shhh,代码行数:5,代码来源:views.py

示例12: index

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def index():
    # return flask.send_from_directory('./static/', 'index.html')
    flask.flash(str((fan.speed, fan.brightness)))
    return flask.render_template("index.html")


# Light Functions 
开发者ID:TomFaulkner,项目名称:SenseMe,代码行数:9,代码来源:flask_app.py

示例13: image_preview

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def image_preview(filename):
    w = request.args.get('w', None)
    h = request.args.get('h', None)
    date = request.args.get('date', None)

    try:
        im = cv2.imread(os.path.join(IMAGE_FOLDER, filename))
        if w and h:
            w, h = int(w), int(h)
            im = cv2.resize(im, (w, h))
        elif date:
            date = (datetime
                    .strptime(date, "%Y%m%d_%H%M%S")
                    .strftime("%d %b %-H:%M")
                    )
            img_h, img_w = im.shape[:-1]
            cv2.putText(
                    im, "{}".format(date), (0, int(img_h*0.98)),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
        return Response(cv2.imencode('.jpg', im)[1].tobytes(),
                        mimetype='image/jpeg')

    except Exception as e:
        print(e)

    return send_from_directory('.', filename) 
开发者ID:cristianpb,项目名称:object-detection,代码行数:28,代码来源:app.py

示例14: status

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def status():
    return send_from_directory('../dist', "index.html") 
开发者ID:cristianpb,项目名称:object-detection,代码行数:4,代码来源:app.py

示例15: build

# 需要导入模块: import flask [as 别名]
# 或者: from flask import send_from_directory [as 别名]
def build(path):
    return send_from_directory('../dist', path) 
开发者ID:cristianpb,项目名称:object-detection,代码行数:4,代码来源:app.py


注:本文中的flask.send_from_directory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。