'How to nicely delete the /static/<path:filename> route from Flask blueprint?

I am trying to nicely delete the /static/<path:filename> route from Flask blueprint. But the unique way I find to do that is using the following instruction:

index = None

for i, url in enumerate(app.url_map._rules):
   if str(url) == '/static/<path:filename>':
      index = i

if index is not None:
   del app.url_map._rules[index]

I've studied the source code and I could not find another way to do that. The code above access some private attributes, broking all encapsulation around url_map.

Someone can help me to find a more appropriate way to do this operation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source