-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blueprint Support #64
Comments
Hello, I had the same problem with quart_discord. discord = DiscordOAuth2Session(app) to your main file, and then import discord from main in your blueprint file. if __name__ == "__main__":
from blueprints.api import api
from blueprints.dashboard import dashboard
app.register_blueprint(api)
app.register_blueprint(dashboard)
app.run(host="localhost", port=5000, debug=True) For me it works perfectly Your blueprint should look like that ...
from flask.blueprints import Blueprint
from main import app, discord
dashboard = Blueprint('dashboard', __name__, url_prefix='/dashboard', template_folder="../templates/dashboard/")
... And your main app = Flask(__name__)
...
discord = DiscordOAuth2Session(app)
if __name__ == "__main__":
from blueprints.api import api
from blueprints.dashboard import dashboard
app.register_blueprint(api)
app.register_blueprint(dashboard)
app.run(host="localhost", port=5000, debug=True) |
Hey, thanks for your reply. I fixed the issue in the end by just using oauthlib and doing it from scratch just because for my case, I can't have discord imported in the main file. |
Hey, I need to use Flask-Discord in a blueprint but I am not sure if that is possible.
I get the error
AttributeError: 'Flask' object has no attribute 'discord'
and I think its because it uses current_app instead of the blueprint itself.Thanks
The text was updated successfully, but these errors were encountered: