Set host for every route in one place? #4235
-
Hiya. I'm doing a bit of cleanup of my code, and one major thing I need to fix is the fact that I define a host for all my routes under host_matching. Currently, my project has multiple views [ie Blueprints, the folder is just called "views"], but every one of them manually imports a variable from a config file to set the "host" that the route is bound to. Is there a way to set that globally in the whole flask app when creating the Flask object so it doesn't need to be set on each individual route? I noticed a "static_host" option, but this appears to be for the routes involving static files [ie "static/something.txt"], and not "all routes in the entire app". Thanks for the response in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
If all routes are for one host, you don't need to use host matching. You can use |
Beta Was this translation helpful? Give feedback.
If all routes are for one host, you don't need to use host matching.
You can use
functools.partial
, or otherwise wtite a decorator, to wrapapp.route
and automatically pass the value you want.