【发布时间】:2023-03-15 03:36:02
【问题描述】:
下面是我的 vue 前端构建(npm rum build on vue-cli 3)。
下面是我用于烧瓶后端的run.py 文件。
from flask import Flask, render_template
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
variable_start_string='%%',
variable_end_string='%%',
))
app = CustomFlask(__name__,
static_folder="./dist",
template_folder="./dist"
)
@app.route('/')
def index():
return render_template("index.html")
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5000)
如您所见,由于我的 dist 结构,我已将默认烧瓶静态模板目录更改为 ./dist。但是当我尝试测试我的应用时,我收到了以下消息。
Chrome 控制台
vendor.97db904d.js Failed to load resource: the server responded with a status of 404 (NOT FOUND)
app.9aaff056.js Failed to load resource: the server responded with a status of 404 (NOT FOUND)
app.197e53a9.css Failed to load resource: the server responded with a status of 404 (NOT FOUND)
vendor.97db904d.js Failed to load resource: the server responded with a status of 404 (NOT FOUND)
app.9aaff056.js Failed to load resource: the server responded with a status of 404 (NOT FOUND)
app.197e53a9.css Failed to load resource: the server responded with a status of 404 (NOT FOUND)
烧瓶
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /js/vendor.97db904d.js HTTP/1.1" 404 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /js/app.9aaff056.js HTTP/1.1" 404 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /css/app.197e53a9.css HTTP/1.1" 404 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /js/vendor.97db904d.js HTTP/1.1" 404 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /js/manifest.ce28c628.js.map HTTP/1.1" 404 -
127.0.0.1 - - [11/Apr/2018 19:44:21] "GET /js/app.9aaff056.js HTTP/1.1" 404 -
如何正确更改烧瓶上的静态/模板目录?或者我应该在 vue-cli3(webpack) 上更改我的构建配置?我对此没有更多的线索。如果可以的话,请给我一个提示。提前谢谢你。
【问题讨论】:
标签: flask webpack vue.js vue-cli