访问woff和ttf文件时的烧瓶蓝图404

时间:2019-08-13 00:58:56

标签: javascript python flask

我尝试从here获取免费模板,并按照此comment将文件捆绑到HTML / CSS。

在此之后,我有了带有HTML / CSS文件的模板,现在我想在我的 Flask 应用中使用它,但似乎是 404 < / strong>当我在蓝图上使用它时。

这是我的项目结构的片段:

├── app
│   ├── models
│   ├── static
│   │   ├── adminator-admin-dashboard
│   │   │   ├── assets
│   │   │   ├── css
│   │   │   │   └── stylesheet.css
│   │   │   ├── images
│   │   │   │   └── logo.png
│   │   │   └── js
│   │   │       ├── a1ecc3b826d01251edddf29c3e4e1e97.woff
│   │   │       ├── bundle.js
│   │   │       ├── e23a7dcaefbde4e74e263247aa42ecd7.ttf
│   │   │       └── vendor.js
│   ├── templates
│   │   ├── main
│   │   │   ├── operator
│   │   │   │   ├── blank.html
│   │   │   │   └── index.html
│   │   │   ├── student
│   │   │   └── teacher
│   ├── users
│   │   ├── operator
│   │   │   ├── __init__.py
│   │   │   └── views.py
│   │   ├── student
│   │   └── teacher
├── config.py
├── run.py
├── requirements.txt

我已向operator注册了蓝图,这是views.py上的operator的摘要:

operator = Blueprint('operator', __name__)

@operator.route('/operator_dashboard')
def operator_dashboard():
    return render_template('main/operator/blank.html')

这是templates/main/operator/blank.html的代码段

<!DOCTYPE html>
<html>
  <head>
    <link href="{{ url_for('static', filename='adminator-admin-dashboard/css/stylesheet.css' )}}" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <script type="text/javascript" src="{{ url_for('static', filename='adminator-admin-dashboard/js/vendor.js', _external=True) }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='adminator-admin-dashboard/js/bundle.js', _external=True) }}"></script>
  </body>
</html>

它已经渲染了模板,但是没有图标和字体样式。 当我尝试访问呈现模板的路由时收到此消息:

127.0.0.1 - - [13/Aug/2019 07:22:19] "GET /operator/operator_dashboard HTTP/1.1" 200 -
127.0.0.1 - - [13/Aug/2019 07:22:20] "GET /operator/a1ecc3b826d01251edddf29c3e4e1e97.woff HTTP/1.1" 404 -
127.0.0.1 - - [13/Aug/2019 07:22:20] "GET /operator/e23a7dcaefbde4e74e263247aa42ecd7.ttf HTTP/1.1" 404 -

我尝试找出状态代码为 404 woff ttf 文件的调用。我是从bundle.js那里得到的,这是调用该文件的函数:

143: function(t, i, a) {
    t.exports = a.p + "a1ecc3b826d01251edddf29c3e4e1e97.woff"
},
144: function(t, i, a) {
    t.exports = a.p + "e23a7dcaefbde4e74e263247aa42ecd7.ttf"
}

即使我已经将 woff ttf 文件放在与bundle.js相同的目录中,就像上面的项目结构一样。

但我仍然收到此消息:

127.0.0.1 - - [13/Aug/2019 07:22:20] "GET /operator/a1ecc3b826d01251edddf29c3e4e1e97.woff HTTP/1.1" 404 -
127.0.0.1 - - [13/Aug/2019 07:22:20] "GET /operator/e23a7dcaefbde4e74e263247aa42ecd7.ttf HTTP/1.1" 404 -

然后我尝试这样称呼它:

143: function(t, i, a) {
    t.exports = a.p + "{{ url_for('static', filename='adminator-admin-dashboard/js/a1ecc3b826d01251edddf29c3e4e1e97.woff') }}"
},
144: function(t, i, a) {
    t.exports = a.p + "{{ url_for('static', filename='adminator-admin-dashboard/js/e23a7dcaefbde4e74e263247aa42ecd7.ttf') }}"
}

然后我得到了:

127.0.0.1 - - [13/Aug/2019 07:42:09] "GET /operator/%7B%7B%20url_for('static',%20filename='adminator-admin-dashboard/js/a1ecc3b826d01251edddf29c3e4e1e97.woff')%20%7D%7D HTTP/1.1" 404 -
127.0.0.1 - - [13/Aug/2019 07:42:09] "GET /operator/%7B%7B%20url_for('static',%20filename='adminator-admin-dashboard/js/e23a7dcaefbde4e74e263247aa42ecd7.ttf')%20%7D%7D HTTP/1.1" 404 -

然后我也尝试像这样直接调用它:

143: function(t, i, a) {
    t.exports = a.p + "/home/myuser/projects/myProjects/app/static/adminator-admin-dashboard/js/a1ecc3b826d01251edddf29c3e4e1e97.woff"
},
144: function(t, i, a) {
    t.exports = a.p + "/home/myuser/projects/myProjects/app/static/adminator-admin-dashboard/js/e23a7dcaefbde4e74e263247aa42ecd7.ttf"
}

但是它仍然是 404

127.0.0.1 - - [13/Aug/2019 07:47:21] "GET /home/tri/projects/AQUR/app/static/adminator-admin-dashboard/js/a1ecc3b826d01251edddf29c3e4e1e97.woff HTTP/1.1" 404 -
127.0.0.1 - - [13/Aug/2019 07:47:22] "GET /home/tri/projects/AQUR/app/static/adminator-admin-dashboard/js/e23a7dcaefbde4e74e263247aa42ecd7.ttf HTTP/1.1" 404 -

那么,..?怎么了,我的蓝图还是bundle.js呢? 即使我尝试从静态文件夹调用该文件,它也始终引用/operator中的 ttf woff 文件。

0 个答案:

没有答案