From c3d4516f7a86c8d33e8a8cfc994f4693244f67a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Wed, 15 Dec 2021 00:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=89=93=E5=88=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 4 ++-- Rating/routes.py | 14 ++++++++++++++ routes.py => Report/routes.py | 2 +- app.py | 8 ++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 Rating/routes.py rename routes.py => Report/routes.py (91%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8afa3ef..a5f7dfc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,8 +4,8 @@ stages: job: stage: deploy script: -# - docker stop tfse_rating -# - docker rm tfse_rating + - docker stop tfse_rating + - docker rm tfse_rating - docker build -t tfse_rating . - docker run -d -p 51012:51012 --name tfse_rating -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro tfse_rating only: diff --git a/Rating/routes.py b/Rating/routes.py new file mode 100644 index 0000000..a334061 --- /dev/null +++ b/Rating/routes.py @@ -0,0 +1,14 @@ +from flask import Blueprint, request, Response + +from Rating.RatingModel import RatingModel + +rating_route = Blueprint('rating', __name__) + + +@rating_route.route('/general_model', methods=['POST']) +def general_model(): + input_data = request.json['input_data'] + model = RatingModel(input_data) + model.save_indicators() + model.save_result() + return {"info": "模型执行成功"}, 200 diff --git a/routes.py b/Report/routes.py similarity index 91% rename from routes.py rename to Report/routes.py index 7c097c3..d92e214 100644 --- a/routes.py +++ b/Report/routes.py @@ -13,7 +13,7 @@ report_route = Blueprint('result', __name__) @report_route.route('/gen_pdf', methods=['POST']) def gen_pdf(): - with open("static/test_data/report_template.json", "r", encoding="utf-8") as f: + with open("../static/test_data/report_template.json", "r", encoding="utf-8") as f: data = json.load(f) req = request.json name = req['企业名称'] diff --git a/app.py b/app.py index 29348d7..1c8787f 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,17 @@ from flask import Flask from flask_cors import * -from routes import report_route +from Rating.routes import rating_route +from Report.routes import report_route app = Flask(__name__) app.config['JSON_SORT_KEYS'] = False -app.register_blueprint(report_route, url_prefix='/tfse_rating/report') CORS(app, supports_credentials=True) +app.register_blueprint(report_route, url_prefix='/tfse_rating/report') +app.register_blueprint(rating_route, url_prefix='/tfse_rating/rating') + + if __name__ == '__main__': app.run()