I am writing an app in which users will be able to store information that they can specify a REST interface for. IE, store a list of products at /<username>/rest/products. Since the URLs are obviously not known before hand, I was trying to think of the best way to implement dynamic URL creation in Flask. The first way I thought of would be to write a catch-all rule, and route the URL from there. But then I am basically duplicating URL routing capabilities when Flask already has them built-in. So, I was wondering if it would be a bad idea to use .add_url_rule() (docs here, scroll down a bit) to attach them directly to the app. Is there a specific reason this shouldn’t be done?
I am writing an app in which users will be able to store information
Share
Every time you execute
add_url_rule()the internal routing remaps the URL map. This is neither threadsafe nor fast. I right now don’t understand why you need user specific URL rules to be honest. It kinda sounds like you actually want user specific applications mounted?Maybe this is helpful: http://flask.pocoo.org/docs/patterns/appdispatch/