1. view.py
from flask import Flask, render_template
# template_folder:模板的位置,
# static_folder:静态文件放的位置(图片/css..),默认叫static
# static_url_path:前端寻找静态文件的前缀, 默认叫/static g跟静态文件夹存放的位置名称,不一样
app = Flask(__name__, template_folder='templates ', static_folder='xx', static_url_path='/yy"')
@app.route('/index')
def index():
return render_template(' index.html ')
if __name__ == '__main__':
app.run()
2. html
Title
{ url_for('static',filename='1.png') }}" alt="">
3. 前端反向解析反向
{ url_for('static',filename='1.png') }}" alt="">