urls.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # -*- coding=UTF-8 -*-
  3. # **************************************************************************
  4. # Copyright © 2016 jianglin
  5. # File Name: urls.py
  6. # Author: jianglin
  7. # Email: xiyang0807@gmail.com
  8. # Created: 2016-07-15 18:12:22 (CST)
  9. # Last Update:星期六 2016-7-30 20:47:52 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from flask import Blueprint
  14. from .views import ask, good, preview, vote_up, vote_down, edit
  15. from .views import TopicAPI, ReplyAPI
  16. site = Blueprint('topic', __name__)
  17. site.add_url_rule('/ask', view_func=ask)
  18. site.add_url_rule('/good', view_func=good)
  19. site.add_url_rule('/preview', view_func=preview, methods=['POST'])
  20. site.add_url_rule('/up/<topicId>', view_func=vote_up, methods=['POST'])
  21. site.add_url_rule('/down/<topicId>', view_func=vote_down, methods=['POST'])
  22. site.add_url_rule('/edit/<topicId>', view_func=edit)
  23. topic_view = TopicAPI.as_view('topic')
  24. # /topic
  25. # /topic post
  26. # /topic/<uid> get,put,delete
  27. site.add_url_rule('',
  28. defaults={'topicId': None},
  29. view_func=topic_view,
  30. methods=['GET'])
  31. site.add_url_rule('', view_func=TopicAPI.as_view('post'), methods=['POST'])
  32. site.add_url_rule('/<topicId>',
  33. view_func=topic_view,
  34. methods=['GET', 'PUT', 'DELETE'])
  35. reply_view = ReplyAPI.as_view('reply')
  36. site.add_url_rule('reply/<topicId>', view_func=reply_view, methods=['POST'])