|
@@ -1,3 +1,5 @@
|
|
|
+import sys
|
|
|
+
|
|
|
from flask import Flask, request, jsonify
|
|
|
|
|
|
from commonUtil import fill_template, fill_template_auto
|
|
@@ -10,10 +12,27 @@ app = Flask(__name__)
|
|
|
# TEMPLATE_FOLDER = "templatesJson"
|
|
|
# DATA_FOLDER = "..\Json\json_data"
|
|
|
|
|
|
+# def resource_path(relative_path):
|
|
|
+# """适配开发环境 + PyInstaller,支持从项目根目录查找资源"""
|
|
|
+# if getattr(sys, 'frozen', False):
|
|
|
+# base_path = sys._MEIPASS
|
|
|
+# else:
|
|
|
+# # 向上两层回退到项目根目录:适配 ByRules 子目录结构
|
|
|
+# base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
|
+# return os.path.join(base_path, relative_path)
|
|
|
+#
|
|
|
+# MAPPING_FILE = resource_path("final/Json/sjgxys.json")
|
|
|
+# TEMPLATE_FOLDER = resource_path("final/ByRules/templatesJson")
|
|
|
+# DATA_FOLDER = resource_path("final/Json/json_data")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
TEMPLATE_FOLDER = os.path.join(BASE_DIR, "templatesJson")
|
|
|
-DATA_FOLDER = os.path.join(BASE_DIR, ".", "Json", "json_data")
|
|
|
-MAPPING_FILE = os.path.join(BASE_DIR, ".", "Json", "省间关系映射.json")
|
|
|
+DATA_FOLDER = os.path.join(BASE_DIR, "..", "Json", "json_data")
|
|
|
+MAPPING_FOLDER = os.path.join(BASE_DIR, "..", "Json", "sjgxys")
|
|
|
+
|
|
|
+MAPPING_FILE = os.path.join(MAPPING_FOLDER, "sjgxys.json")
|
|
|
|
|
|
|
|
|
@app.route('/process_query', methods=['POST'])
|