__init__.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 ArticleDB
  8. def AlgRoutes(mysql_client, model):
  9. """
  10. ALG ROUTES
  11. :return:
  12. """
  13. blueprint = Blueprint("LongArticlesAlgServer", __name__)
  14. @blueprint.route("/healthCheck")
  15. def helloFuture():
  16. """
  17. 测试服务连通性
  18. :return:
  19. """
  20. response = {"msg": "Hello, World! Hello, Future"}
  21. return jsonify(response)
  22. @blueprint.route("/articleRank", methods=["POST"])
  23. async def articleRankRoute():
  24. """
  25. 文章排序接口
  26. :return:
  27. """
  28. params = await request.get_json()
  29. AAR = AccountArticleRank(params, mysql_client=mysql_client)
  30. response = await AAR.deal()
  31. # print(response)
  32. return jsonify(response)
  33. @blueprint.route("/nlp", methods=["POST"])
  34. async def nlper():
  35. """
  36. nlper ma
  37. :return:
  38. """
  39. params = await request.get_json()
  40. nlpS = NLPServer(params=params, model=model)
  41. response = nlpS.deal()
  42. return jsonify(response)
  43. @blueprint.route("/score_list", methods=["POST"])
  44. async def articleAccount():
  45. """
  46. 公众号文章功能等接口
  47. :return:
  48. """
  49. params = await request.get_json()
  50. return jsonify(params)
  51. @blueprint.route("/article_db", methods=["POST"])
  52. async def articleMysql():
  53. """
  54. 长文数据库相关接口
  55. :return:
  56. """
  57. params = await request.get_json()
  58. ADB = ArticleDB(params=params, mysql_client=mysql_client)
  59. response = await ADB.deal()
  60. return jsonify(response)
  61. return blueprint