flask默认静态目录是static,现在要修改成自定义的myfolder目录,文件结构如下图
/app.py
/static
/js
/img
/css
/myfolder
/js
/img
/css
/templates
index.html
默认静态目录是static,app.py 代码如下:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('index.html')
现在要修改成myfolder目录,只需要实例化app时添加参数即可
app = Flask(__name__,static_folder='myfolder')
from flask import Flask, render_template
app = Flask(__name__,static_folder='myfolder')
@app.route('/')
def hello_world():
return render_template('index.html')