flask: serve static file

Send a file from a given directory with :func:send_file. This
is a secure way to quickly expose static files from an upload folder or something similar.

from flask import Flask, request, send_from_directory

# set the project root directory as the static folder, you can set others.
app = Flask(__name__, static_url_path='')

@app.route('/js/<path:path>')
def send_js(path):
    return send_from_directory('js', path)

if __name__ == "__main__":
    app.run()
添加评论
取消
*
*
*
*
勇士!消灭0条评论,这么艰巨的任务就靠你了!