Javascript 如何使用Flask加载JS或CSS文件,而不更改`<;脚本>;`标签内容?
我的烧瓶设置目前是这样的Javascript 如何使用Flask加载JS或CSS文件,而不更改`<;脚本>;`标签内容?,javascript,python,html,flask,Javascript,Python,Html,Flask,我的烧瓶设置目前是这样的 +project app.py +template index.html +script mn.js mn.js如下所示: alert("hello"); <head> <script src="script/mn.js"> </head> app= Flask(__name__, template_folder='template') index.html引用如下脚本: alert("
+project
app.py
+template
index.html
+script
mn.js
mn.js
如下所示:
alert("hello");
<head>
<script src="script/mn.js">
</head>
app= Flask(__name__, template_folder='template')
index.html
引用如下脚本:
alert("hello");
<head>
<script src="script/mn.js">
</head>
app= Flask(__name__, template_folder='template')
我运行Flask并转到localhost URL。但是alert()
从不触发。我在浏览器控制台中看到一个404
错误,说明它找不到http://127.0.0.1:5000/script/mn.js
在不更改
index.html中
标记的内容的情况下,如何使Flask loadmn.js
?在项目
文件夹中创建一个脚本
文件夹,并将mn.js
放入该文件夹中
现在更新
app=Flask(\uuuuu name\uuuuuu,static\u folder='script',template\u folder='template')
有关Flask中静态文件的更多详细信息,您可以查看它是吗?这会显示什么?您需要更改脚本标记并重新构建项目。有一种方法可以包含在@jornsharpeis共享的链接中找到的静态文件。如果不更改脚本
标记,则无法执行此操作?仍然会出现404错误