How To Access File From An External Folder In Flask Server?
I am new to flask and am very confused regarding including libraries from external folders into the html template. I know how to include from the static folder, but I want to keep
Solution 1:
In general serving static files with flask is only good for development. Realistically, when going live it is advised to serve static files otherwise, for example having a web server in front of your app and delegating file serving to it, or putting the files in a file store, like AWS S3.
Regarding your custom_static
route, cdn
in this case is simply a url prefix (it can be anything), you can then address your static assets from templates like <img src="/cdn/test.jpg">
. (The cdn
prefix can give you a hint that these files are later moved to a CDN and aren't served by flask in production).
app.config['CUSTOM_STATIC_PATH']
should be set to the absolute path to the directory containing your custom static files.
Post a Comment for "How To Access File From An External Folder In Flask Server?"