Reputation: 33
I have a router
@app.route('/images/<filename>')
def images(filename):
send from(os.path.join('uploads', filename))
My images are saved in some directory called 'uploads'. And I configure nginx to serve static files.
My question is when I use url_for('images', filename='1.jpg') in jinja template, which should generate something like src="/images/1.jpg" in browser, if the user click this link, will nginx serve the file or flask serve it?
Another example: when using url_for('static', filename='style.css') in template, is nginx serving it?
Upvotes: 2
Views: 1042
Reputation: 44092
The solution shall work well, if follows these rules:
Under these (production) conditions, your Python code shall not get requests to these static files as they are served by nginx.
This is desired behaviour, as it off-loads python application by nginx, which can serve those files much more efficiently.
Upvotes: 0