0

How do I prevent mysite.com/static from being visible and accessible for everyone? I discovered that it's accessible by accident.

I am using Flask and Python3.

I don't know how to prevent this.

user3151858
  • 790
  • 4
  • 13
  • 26
  • Are you running flask with the built in web server? – Alden Dec 27 '16 at 23:24
  • I am using Apache2 and wod-wsgi to run server, and Flask as web framework. – user3151858 Dec 28 '16 at 00:36
  • Possibly related to http://stackoverflow.com/questions/2530372/how-do-i-disable-directory-browsing – danidee Dec 28 '16 at 14:53
  • Flask recommends that a static folder be served by your web server (Apache in your case), but also has the capability of serving static files. There must either be a rule in your apache configuration or a view in your flask app that is allowing access to the static folder. – Alden Dec 28 '16 at 15:21

1 Answers1

0

Flask creates the /static/<filename> route by default.

You can prevent that by setting static_folder to None when you instantiate Flask:

app = Flask(__name__, static_folder=None)
mcf9y0
  • 61
  • 1