authorisation.pyBir paket api'sinde bulunan bir plan içindeki erişim uygulaması yapılandırmasına erişmeye çalışıyorum . İçinde __init__.pykullanılan planı başlatıyorum authorisation.py.
__init__.py
from flask import Blueprint
api_blueprint = Blueprint("xxx.api", __name__, None)
from api import authorisation
authorisation.py
from flask import request, jsonify, current_app
from ..oauth_adapter import OauthAdapter
from api import api_blueprint as api
client_id = current_app.config.get('CLIENT_ID')
client_secret = current_app.config.get('CLIENT_SECRET')
scope = current_app.config.get('SCOPE')
callback = current_app.config.get('CALLBACK')
auth = OauthAdapter(client_id, client_secret, scope, callback)
@api.route('/authorisation_url')
def authorisation_url():
url = auth.get_authorisation_url()
return str(url)
RuntimeError alıyorum: uygulama bağlamının dışında çalışıyor
Bunun neden olduğunu anlıyorum ama o zaman bu yapılandırma ayarlarına erişmenin doğru yolu nedir?
---- Güncelle ---- Geçici olarak, bunu yaptım.
@api.route('/authorisation_url')
def authorisation_url():
client_id, client_secret, scope, callback = config_helper.get_config()
auth = OauthAdapter(client_id, client_secret, scope, callback)
url = auth.get_authorisation_url()
return str(url)
current_appProxy'nin yalnızca bir istek bağlamında kullanılabildiğini unutmayın .