烧瓶无法识别静态文件夹

时间:2019-02-04 17:31:08

标签: flask

我最近重新整理了项目文件夹,并将静态文件夹放入了新的视图文件夹中。

/view
- /static
- /templates
main-controller.py

当我在main-controller.py中调用Flask应用程序时,我在构造函数中定义了新的视图文件夹:

app = Flask(__name__, root_path='view/')

当我启动Flask服务器时,它会在模板中渲染模板页面,但是不会从静态文件夹中渲染任何东西,从而收到如下页面错误:

Failed to load resource: style.css:1 
the server responded with a status of 404 (NOT FOUND)

Failed to load resource: script.js:1 
the server responded with a status of 404 (NOT FOUND)

在session.html中通过以下方式调用

<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles/style.css') }}">

<script type="text/javascript"  src="{{ url_for('static', filename='script.js') }}"></script>

为什么找不到静态文件夹却找不到模板文件夹呢?

0 个答案:

没有答案
相关问题