मैं एक ब्लूप्रिंट के अंदर एक्सेस एप्लिकेशन कॉन्फ़िगरेशन को एक्सेस करने की कोशिश कर रहा हूं authorisation.pyजो एक पैकेज एपी में है। मैं उस ब्लूप्रिंट को इनिशियलाइज़ कर रहा हूँ __init__.pyजिसमें प्रयोग किया जाता है 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 मिल रहा है: एप्लिकेशन संदर्भ के बाहर काम करना
मैं समझता हूं कि ऐसा क्यों है, लेकिन फिर उन कॉन्फ़िगरेशन सेटिंग्स तक पहुंचने का सही तरीका क्या है?
---- अद्यतन ---- अस्थायी रूप से, मैंने यह किया है।
@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_appप्रॉक्सी केवल एक अनुरोध के संदर्भ में उपलब्ध है।