Forums

Blocking access to static folders

What is the easiest way to deny direct access to some of my static folders, for example /static/img in my Flask application?

I don't think there's any way of selectively blocking access to specific subdirectories once you've added a parent directory to a static file mapping.

One question -- what do you mean by "direct" access?

What I mean is, how can I make certain directories not accessible by browsing, so that navigating to such folder would show 403 error to visitor. For example in php / apache environment I would do this in .htaccess file.

If you don't want a static file directory to be browsable, just don't make a static file mapping to it.

I guess that's the best way. Thank you!