Is It Possible To Change `template_folder` After Initialisation?
Using this Flask bootstrap project, I'd like to specify some parameters that must be defined in the Flask object creation (like template_folder, static_url_path and static_path) He
Solution 1:
You MIGHT be able to change some of these, but Flask is not designed to handle changing these on the app after the app is created. Just looking at some to the code, for example, the static route is created in the constructor of the Flask application.
So, you will need to set these parameters at build time. The good news is that your configuration is typically done in a way that can be pretty easily loaded (e.g., in a python module). You should be able to change your bootstrap to:
app_name = app_name or __name__
config = config_str_to_obj(config)
app = Flask(app_name, static_url_path=config.SOME_CONFIGURATION_NAME)
configure_app(app, config)
...
Post a Comment for "Is It Possible To Change `template_folder` After Initialisation?"