Flask实例化配置
template_folder :指定模板存放路径,默认值:temolates
from flask import Flask, url_for app = Flask(__name__,template_folder="tem") @app.route("/index") def index(): return "光临" if __name__ == '__main__': app.run(debug=True)
static_folder和static_url_path
from flask import Flask, url_for app = Flask(__name__,static_folder="statics",static_url_path="/static")
#static_folder="statics", # 指定静态文件存放路径 默认值:static #static_url_path="/static" # 指定静态文件访问路径 默认值:- "/{static_folder}" @app.route("/index") def index(): return "光临" if __name__ == '__main__': app.run(debug=True)
以下为不常用配置,可以使用nginx实现
static_host=None #远程静态文件存放服务器 host_matching=False #为True:遵循主机位匹配 http://www.baidu.com/index subdomain_matching=False # True:严格遵循子域名访问subdomain - sub - 子域名 music.baidu.com/music.html