1
내 문제에 this answer을 사용하려고하는데 올바르게 사용하는 방법을 모르겠습니다.Flask의 send_static_file()을 재정의하십시오.
내 코드 : 플라스크의
Traceback (most recent call last):
File "/home/honza/Stažené/pycharm-community-3.0/helpers/pydev/pydevd.py", line 1498, in <module>
debugger.run(setup['file'], None, None)
File "/home/honza/Stažené/pycharm-community-3.0/helpers/pydev/pydevd.py", line 1139, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "/home/honza/workspace/web_development/login/toneid_web_api_jk.py", line 37, in <module>
class SecuredStaticFlask(app):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 507, in __init__
self.add_url_rule(self.static_url_path + '/<path:filename>',
TypeError: Error when calling the metaclass bases
can only concatenate tuple (not "str") to tuple
인스턴스 :
응용 프로그램 = 플라스크 (이름)
app = Flask(__name__, static_folder="static", static_path="")
class SecuredStaticFlask(app):
def send_static_file(self, filename):
# Get user from session
if current_user.is_authenticated():
return super(SecuredStaticFlask, self).send_static_file(filename)
else:
abort(403)
내가 브라우저에서 http://localhost:5000/some_existing_file
를 방문 할 때, 플라스크 나에게 오류를 제공 .Flask는 app
맞지? 그래서 플라스크의 하위 클래스는 subclass_name(parent_class)
입니다.
아무도 도와 줄 수 있습니까? 감사. 이 라인에서 제 생각에는