Skip to content

Instantly share code, notes, and snippets.

@rtzll
Last active February 16, 2023 22:27
Show Gist options
  • Save rtzll/8f0f7668c4ca9813e9380b45b932e7c2 to your computer and use it in GitHub Desktop.
Save rtzll/8f0f7668c4ca9813e9380b45b932e7c2 to your computer and use it in GitHub Desktop.
Using the app context in a flask blueprint
from flask import Flask
from blueprint import sample
app = Flask(__name__)
app.register_blueprint(sample)
app.config['SOMETHING'] = 'something'
if __name__ == '__main__':
app.run()
from flask import Blueprint, current_app
sample = Blueprint('sample', __name__)
@sample.route('/')
def index():
return current_app.config['SOMETHING']
@rtzll
Copy link
Author

rtzll commented Sep 30, 2016

Run python app.py and visit http://localhost:5000/, there you will see something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment