By default if exist static
folder flask have static
endpoint which maped static
url path to static
folder path. You can change static_url_path
or static_folder
flask argument to another (not static
).
If you want require login for static endpoint then you can try next code:
@app.before_request
def check_login():
if request.endpoint == 'static' and not current_user.is_authenticated():
abort(401)
return None
or override send_static_file
view function:
def send_static_file(self, filename):
if not current_user.is_authenticated():
abort(401)
return super(Flask, self).send_static_file(filename)