邓淳远、崔鹏宇、翁思扬组云计算期末项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.8 KiB

4 years ago
4 years ago
4 years ago
  1. from flask import Flask, render_template, request, jsonify, session, Blueprint
  2. from bson import json_util
  3. bp = Blueprint("collection", __name__,url_prefix="/collection")
  4. @bp.route("/add", methods=["POST"])
  5. def add_collection():
  6. name = request.form.get('name')
  7. tag = request.form.get('tag', None)
  8. ret = {'msg':'succuss','name':name}
  9. """
  10. ret['id'] =
  11. """
  12. return json_util.dumps(ret)
  13. @bp.route("/select", methods=["POST"])
  14. def get_collection():
  15. # 搜索的关键词
  16. name = request.form.get('name', None)
  17. # 搜索对象
  18. phonenum = request.form.get('phonenum',None)
  19. collections = []
  20. """
  21. collections.append({'id': '1', 'name': 'xuanz','like':1})
  22. collections.append({'id': '2', 'name': 'mingg','like':2})
  23. collections.append({'id': '3', 'name': 'wnqian','like':3})
  24. """
  25. ret = {'collections':collections,'msg':'succuss'}
  26. return json_util.dumps(ret)
  27. @bp.route("/recommand", methods=["POST"])
  28. def get_collection():
  29. collections = []
  30. """
  31. collections.append({'id': '1', 'name': 'xuanz','like':1})
  32. collections.append({'id': '2', 'name': 'mingg','like':2})
  33. collections.append({'id': '3', 'name': 'wnqian','like':3})
  34. """
  35. ret = {'collections':collections,'msg':'succuss'}
  36. return json_util.dumps(ret)
  37. @bp.route("/isLike", methods=["POST"])
  38. def islike():
  39. ret = {'msg': 'succuss'}
  40. id = request.form.get('collection_id')
  41. """
  42. session确定id的collection是否有点赞
  43. ans['isLike'] = True
  44. """
  45. return json_util.dumps(ret)
  46. @bp.route("/like", methods=["POST"])
  47. def get_like():
  48. id = request.form.get('colllection_id')
  49. """
  50. """
  51. ret = {'msg':'succuss'}
  52. return json_util.dumps(ret)
  53. @bp.route("/unlike", methods=["POST"])
  54. def get_unlike():
  55. id = request.form.get('colllection_id')
  56. """
  57. """
  58. ret = {'msg':'succuss'}
  59. return json_util.dumps(ret)
  60. @bp.route("/swap", methods=["POST"])
  61. def swap():
  62. id = request.form.get('id')
  63. order = request.form.get('new_order')
  64. """
  65. id的collection和顺序是order的collection交换
  66. """
  67. ret = {'msg':'succuss'}
  68. return json_util.dumps(ret)
  69. @bp.route("/delete", methods=["POST"])
  70. def delete():
  71. id = request.form.get('collection_id')
  72. """
  73. id的collection
  74. """
  75. ret = {'msg':'succuss'}
  76. return json_util.dumps(ret)
  77. @bp.route("/edit", methods=["POST"])
  78. def edit():
  79. id = request.form.get('collection_id')
  80. name = request.form.get('name', None)
  81. tag = request.form.get('tag', None)
  82. """
  83. none的情况请直接返回
  84. """
  85. ret = {'msg':'succuss'}
  86. return json_util.dumps(ret)