views.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # **************************************************************************
  4. # Copyright © 2016 jianglin
  5. # File Name: views.py
  6. # Author: jianglin
  7. # Email: xiyang0807@gmail.com
  8. # Created: 2016-11-09 21:06:32 (CST)
  9. # Last Update:星期四 2016-12-22 22:46:16 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from flask import (Blueprint, render_template, send_from_directory)
  14. from flask.views import MethodView
  15. site = Blueprint(
  16. 'docs',
  17. __name__,
  18. url_prefix='/docs',
  19. template_folder='templates',
  20. static_folder='static')
  21. class DocListView(MethodView):
  22. def get(self):
  23. return render_template('docs/doc_list.html')
  24. class DocView(MethodView):
  25. def get(self, path):
  26. return send_from_directory(site.static_folder, path)
  27. doclist_view = DocListView.as_view('list')
  28. doc_view = DocView.as_view('doc')
  29. site.add_url_rule('', view_func=doclist_view)
  30. site.add_url_rule('/<path:path>', view_func=doc_view)