python - Flask and auto-reloading in new CLI
问题描述
I have a web application in flask that uses rest-plus for some CRUD operations. I'm using Swagger to test endpoints.
Recently i migrated my project to use new Flask CLI instead of Flask-Script (using Manager instance to add commands).
However there is a big change I've witnessed w.r.t. reloader... Previously every time I made a change in code, after server was already running there was information about reloading, and traceback in case of error in terminal. I think whole application was restarted each time?
Now, after migrating to CLI there is no such thing (at least not visible in terminal) and in order to see error I have to open up my server in browser or refresh browser, and the traceback is visible both in browser and terminal afterwards also there is no information about reloading in terminal.
I'd like to know whether it's caused by this new CLI or maybe I messed something else up in the meantime.
Which behavior is the correct one and is there any way I can get back auto-reloading in terminal without having to refresh web browser each time?
Thanks in advance,
Cheers
解决方案
确保你在开发模式下运行你的烧瓶服务器。例如:
export FLASK_ENV=development
export FLASK_APP=app.py
flask run
日志应该是这样的:
* Environment: development
* Debugger is active!
推荐阅读
- html - 是什么导致滚动条落后于固定 div
- javafx - 如何平移 JavaFX LineChart
- android - Firestore Get:指定失败侦听器有用还是我们可以只使用 if(!task.isSuccessful())?
- java - 如何修改 Rod-Cutting 问题以使尺寸增加一倍以上
- c# - 在单个 if 语句中使用多个“is”变量
- python - 重复 ndarray n 次
- sparql - Virtuoso 42000 错误估计的执行时间
- git - 我可以从本地分支中删除目录,但将目录保留在远程存储库中吗
- php - 如何在wordpress搜索查询中用“”去除/替换倾斜的双引号?
- python - 如何使用numpy将0添加到列表列表的末尾?