python - Flask-JWT doesn't seem to recognize current_app -


i want use flask-jwt app. when try initialize current_app, error. point i've been using current_app in place of app = flask(__name__) bit unexpected. there i'm missing?

from flask import current_app flask_jwt import jwt  def authenticate(username, password):   ...   return user  def identity(payload):   ...   return userid_table.get(user_id, none)  jwt = jwt(current_app, authenticate, identity) 
traceback (most recent call last):   file "./wsgi.py", line 1, in <module>     main import app application   file "./main.py", line 5, in <module>     auth import api_auth   file "./auth.py", line 59, in <module>     jwt = jwt(current_app, authenticate, identity)   file "/opt/mist_base/env/lib/python2.7/site-packages/flask_jwt/__init__.py", line 216, in __init__     self.init_app(app)   file "/opt/mist_base/env/lib/python2.7/site-packages/flask_jwt/__init__.py", line 220, in init_app     app.config.setdefault(k, v)   file "/opt/mist_base/env/lib/python2.7/site-packages/werkzeug/local.py", line 343, in __getattr__     return getattr(self._get_current_object(), name)   file "/opt/mist_base/env/lib/python2.7/site-packages/werkzeug/local.py", line 302, in _get_current_object     return self.__local()   file "/opt/mist_base/env/lib/python2.7/site-packages/flask/globals.py", line 51, in _find_app     raise runtimeerror(_app_ctx_err_msg) runtimeerror: working outside of application context. 

you need initialize class 'current_app' before can use it.

current_app = flask(__name__) 

Comments