Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. yourapp/
  2. __init__.py
  3. static/
  4. templates/
  5. home/
  6. blog/
  7. views/
  8. __init__.py
  9. home.py
  10. blog.py
  11. models.py
  12.  
  13. # home.py
  14.  
  15. home = Blueprint('home', __name__)
  16.  
  17. @home.route('/')
  18. def index():
  19. ...
  20. return render_template('index.html',
  21. url=call_some_shared_code)
  22.  
  23. # blog.py
  24.  
  25. blog = Blueprint('blog', __name__)
  26.  
  27. @blog.route('/')
  28. def index():
  29. ...
  30. return render_template('blog.html',
  31. url=call_some_shared_code)
  32.  
  33. yourapp/
  34. __init__.py
  35. static/
  36. templates/
  37. home/
  38. blog/
  39. views/
  40. __init__.py
  41. home.py
  42. blog.py
  43. models.py
  44. common.py # <-- shared code
  45.  
  46. #common.py
  47.  
  48. def get_url():
  49. return session.get('url') or current_app.config.get('URL')
  50.  
  51. def get_connection():
  52. return client.connect(get_url(),
  53. auth_type=session.get('auth_type'),
  54. username=session.get('username'),
  55. password=session.get('password'))
  56.  
  57. # blog.py
  58. from yourapp import common
  59.  
  60. blog = Blueprint('blog', __name__)
  61.  
  62. @blog.route('/')
  63. def index():
  64. ...
  65. client = client.get_client('group',
  66. connection=common.get_connection())
  67. ...
  68. return render_template('blog.html',
  69. url=common.get_url())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement