Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- yourapp/
- __init__.py
- static/
- templates/
- home/
- blog/
- views/
- __init__.py
- home.py
- blog.py
- models.py
- # home.py
- home = Blueprint('home', __name__)
- @home.route('/')
- def index():
- ...
- return render_template('index.html',
- url=call_some_shared_code)
- # blog.py
- blog = Blueprint('blog', __name__)
- @blog.route('/')
- def index():
- ...
- return render_template('blog.html',
- url=call_some_shared_code)
- yourapp/
- __init__.py
- static/
- templates/
- home/
- blog/
- views/
- __init__.py
- home.py
- blog.py
- models.py
- common.py # <-- shared code
- #common.py
- def get_url():
- return session.get('url') or current_app.config.get('URL')
- def get_connection():
- return client.connect(get_url(),
- auth_type=session.get('auth_type'),
- username=session.get('username'),
- password=session.get('password'))
- # blog.py
- from yourapp import common
- blog = Blueprint('blog', __name__)
- @blog.route('/')
- def index():
- ...
- client = client.get_client('group',
- connection=common.get_connection())
- ...
- return render_template('blog.html',
- url=common.get_url())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement