Adding static resources
Static resources provide the user experience for Flask web applications. These static resources include the needed CSS, JavaScript, images, and video files to be used by some template pages. Now, Flask does not allow adding these files anywhere in the project. Generally, the Flask constructor has a static_folder
parameter that accepts a relative path of a dedicated directory for these files.
In ch02-factory
, create_app()
configures the Flask instance to allow placing the resources in the /resources
folder of the main project directory. The following snippet of create_app()
shows the Flask instantiation with the resource
folder setup:
def create_app(config_file): app = Flask(__name__, template_folder='../app/pages', static_folder='../app/resources') app.config.from_file(config_file...