__init__.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Blueprint, jsonify, request
  5. from .AccountArticleRank import AccountArticleRank
  6. from .nlpServer import NLPServer
  7. def AlgRoutes(mysql_client, model):
  8. """
  9. ALG ROUTES
  10. :return:
  11. """
  12. blueprint = Blueprint("LongArticlesAlgServer", __name__)
  13. @blueprint.route("/healthCheck")
  14. def helloFuture():
  15. """
  16. 测试服务连通性
  17. :return:
  18. """
  19. response = {"msg": "Hello, World! Hello, Future"}
  20. return jsonify(response)
  21. @blueprint.route("/articleRank", methods=["POST"])
  22. async def articleRankRoute():
  23. """
  24. 文章排序接口
  25. :return:
  26. """
  27. params = await request.get_json()
  28. AAR = AccountArticleRank(params, mysql_client=mysql_client)
  29. response = await AAR.deal()
  30. # print(response)
  31. return jsonify(response)
  32. @blueprint.route("/nlp", methods=["POST"])
  33. async def nlper():
  34. """
  35. nlper ma
  36. :return:
  37. """
  38. params = await request.get_json()
  39. nlpS = NLPServer(params=params, model=model)
  40. response = nlpS.deal()
  41. return jsonify(response)
  42. return blueprint