Serving a dynamically generated file in Flask [duplicate] Serving a dynamically generated file in Flask [duplicate] flask flask

Serving a dynamically generated file in Flask [duplicate]


You can use send_from_directory() to serve files from /data.

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


Why not have the caching logic in the action function? If the file has already been cached then feed it out from a single file load. I would imaging you would also want access control and that would not happen by serving static files from the HTTP service.