I followed the instructions from How to serve static files in Flask, but still couldn\'t get it working.
Here\'s my project structure:
Project_path
All you need to do is, pass the static_folder parameter to the initiator:
static_url_path
– can be used to specify a different path for the static files on the web. Defaults to the name of thestatic_folder
folder.
static_folder
– the folder with static files that should be served at static_url_path. Defaults to the 'static' folder in the root path of the application.
app = Flask(__name__, static_folder=os.path.abspath('/foo/bar/zoo/'))
Now, flask will look for a directory named static
in /foo/bar/zoo
from where to serve static files. You only use send_from_directory
if you are serving media files which may not be in the same location as static files.