首页 > 解决方案 > 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

标签: pythonflask

解决方案


确保你在开发模式下运行你的烧瓶服务器。例如:

export FLASK_ENV=development
export FLASK_APP=app.py
flask run

日志应该是这样的:

 * Environment: development
 * Debugger is active!

推荐阅读