pip install livereload
文档:https://pypi.org/project/livereload/
代码
#coding=utf-8 from flask import Flask from flask_script import Manager app = Flask(__name__) # 使用manager管理工具 manager = Manager(app) @app.route("/") def upload(): return "hello nihao" # 实现自动刷新调试功能 @manager.command def dev(): from livereload import Server live_server = Server(app.wsgi_app) live_server.watch("**/*.*") live_server.serve(open_url=True) if __name__ == "__main__": manager.run() #python main.py dev
或者
from livereload import Server if __name__ == '__main__': app.debug = True live_server = Server(app.wsgi_app) # live_server.watch('**/*.*') live_server.serve() # app.run()
参考