__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Blueprint, jsonify, request
  5. from .accountArticleRank import AccountArticleRank
  6. from .nlpServer import NLPServer
  7. from .articleDBServer import ArticleSpider
  8. from .accountServer import AccountServer
  9. from applications.articleTools import ArticleDBTools
  10. def AlgRoutes(mysql_client, model):
  11. """
  12. ALG ROUTES
  13. :return:
  14. """
  15. blueprint = Blueprint("LongArticlesAlgServer", __name__)
  16. @blueprint.route("/healthCheck")
  17. def helloFuture():
  18. """
  19. 测试服务连通性
  20. :return:
  21. """
  22. response = {"msg": "Hello, World! Hello, Future"}
  23. return jsonify(response)
  24. @blueprint.route("/articleRank", methods=["POST"])
  25. async def articleRankRoute():
  26. """
  27. 文章排序接口
  28. :return:
  29. """
  30. params = await request.get_json()
  31. AAR = AccountArticleRank(params, mysql_client=mysql_client)
  32. response = await AAR.deal()
  33. # print(response)
  34. return jsonify(response)
  35. @blueprint.route("/nlp", methods=["POST"])
  36. async def nlper():
  37. """
  38. nlper ma
  39. :return:
  40. """
  41. params = await request.get_json()
  42. nlpS = NLPServer(params=params, model=model)
  43. response = nlpS.deal()
  44. return jsonify(response)
  45. @blueprint.route("/score_list", methods=["POST"])
  46. async def articleAccount():
  47. """
  48. 公众号文章功能等接口
  49. :return:
  50. """
  51. params = await request.get_json()
  52. AS = AccountServer(mysql_client=mysql_client, params=params)
  53. response = await AS.deal()
  54. return jsonify(response)
  55. @blueprint.route("/title_list", methods=["POST"])
  56. async def accountTitle():
  57. """
  58. 获取账号的标题list
  59. :return:
  60. """
  61. params = await request.get_json()
  62. print(params)
  63. ADBT = ArticleDBTools(mysql_client=mysql_client)
  64. responseDF = await ADBT.getArticleByFilter(
  65. account_name=params['account_name'],
  66. index_list=params['index_list'],
  67. min_time=params['min_time'],
  68. max_time=params['max_time'],
  69. msg_type=params['msg_type'],
  70. )
  71. title_list = responseDF['title']
  72. response = {"title_list": title_list.values.tolist()}
  73. return jsonify(response)
  74. @blueprint.route("/article_crawler", methods=["POST"])
  75. async def articleMysql():
  76. """
  77. 长文数据库相关接口
  78. :return:
  79. """
  80. params = await request.get_json()
  81. ADB = ArticleSpider(params=params, mysql_client=mysql_client)
  82. response = await ADB.deal()
  83. return jsonify(response)
  84. return blueprint