flask加载静态文件

1.加载静态文件需要使用 url_for ,第一个参数为  static,第二个参数 为  file = ‘’(同样的绝对路径)

2.静态文件包含,js,css,images等文件

示例语法为:

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href='{{ url_for("static",filename = "css/index.css" ) }}'>
    <script src="{{ url_for("static",filename = "js/js.js") }}">

    </script>
</head>

猜你喜欢

转载自blog.csdn.net/hebi123s/article/details/81985979