Flask 自定义template和静态文件路径

这边使用flask的时候希望规范下路径,就需要重新移动默认的template的路径,所以就需要自定义路径了,查了下。记录

就直接在app.py里面进行修改,加两个属性,第一个就是放html的第二个就是放css/js那些静态文件的

python 复制代码
 app = Flask(__name__,template_folder='webapp/templates',static_folder='webapp/content')

或者直接在blueprint定义里面修改

python 复制代码
blueprint = Blueprint("example", __name__, template_folder="webapp/template/custom")

修改完记得重新启动,热部署无法加载这个修改。

相关推荐
stephon_10018 小时前
Agent 接入 MCP 后上下文爆炸、工具选串?一种“按需激活“的工具加载方案(含实现)
人工智能·python·ai
TickDB18 小时前
统一行情 API 查 A 股、港股、美股和数字货币:code=0 不代表 symbol 一个没少
人工智能·python·websocket·mcp·行情数据 api
独泪了无痕1 天前
MyBatis魔法堂:结果集映射
后端·mybatis
大貔貅喝啤酒1 天前
Python Requests库教程
自动化测试·python·requests库
copyer_xyf1 天前
LangChain 调用 LLM
后端·python·agent
copyer_xyf1 天前
Prompt 组织管理
后端·python·agent
shimly1234561 天前
python3 uvicorn 是啥?
python
CTA量化套保1 天前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
摇滚侠1 天前
SpringMVC 入门到实战 文件上传 75-77
java·后端·spring·maven·intellij-idea
GIS数据转换器1 天前
城市排水生命线安全运行监测平台深度解析
java·运维·人工智能·python·安全·数据挖掘·无人机