diff --git a/main.py b/main.py index 67cda3e9769b2a68b84e586a8b11c1b5bfd9dd07..8aa4e2d36227bce60c4818b1b6a90f402697118f 100644 --- a/main.py +++ b/main.py @@ -37,6 +37,7 @@ relative_path = venv_path # 获取绝对路径 absolute_path = os.path.abspath(os.path.join(base_dir, relative_path)) +# TODO:修复模板路径问题 app = Flask(__name__, template_folder='./', static_folder='./') # 判断是否存在project虚拟环境,不存在则创建 @@ -64,17 +65,17 @@ if not os.path.exists('project'): f.write(json.dumps(data)) -# 定义一个路由,当访问根目录时,返回editor.html模板 +# 定义一个路由,当访问根目录时,返回index.html模板 @app.route('/') def index(): # 如果 Cookie 不存在或为空,设置一个默认值 if not request.cookies.get('currentProjectPath'): # 创建一个响应对象 - response = make_response(render_template('index.html')) + response = make_response(render_template('/dist/index.html')) # 设置 Cookie response.set_cookie('currentProjectPath', value=absolute_path, max_age=3600*24*7) return response - return render_template('index.html') + return render_template('/dist/index.html') @app.route('/docs/') @@ -92,7 +93,7 @@ def static_proxy(path): def api(api): if not request.cookies.get('currentProjectPath'): # 创建一个响应对象 - response = make_response(render_template('index.html')) + response = make_response(render_template('/dist/index.html')) # 设置 Cookie response.set_cookie('currentProjectPath', value=absolute_path, max_age=3600*24*7) return response