views.py 1012 B

123456789101112131415161718192021222324252627282930313233
  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:星期日 2017-4-2 12:16:48 (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', __name__, template_folder='templates', static_folder='static')
  17. class DocListView(MethodView):
  18. def get(self):
  19. return render_template('docs/doc_list.html')
  20. class DocView(MethodView):
  21. def get(self, path):
  22. return send_from_directory(site.static_folder, path)
  23. doclist_view = DocListView.as_view('list')
  24. doc_view = DocView.as_view('doc')
  25. site.add_url_rule('/', view_func=doclist_view)
  26. site.add_url_rule('/<path:path>', view_func=doc_view)