烧瓶应用程序 - 本地开发环境 - 变化不反映

发布于 2025-01-28 11:38:30 字数 427 浏览 5 评论 0原文

我有一个在本地运行和测试的烧瓶应用程序。每次我对应用程序代码进行更改,更改都会反映Dev环境http://127.0.0.1:8000/使用简单的浏览器刷新。

现在,我必须终止烧瓶应用ctrl x + ctrl c,然后重新启动/重新启动应用程序。我正在使用Gunicorn启动烧瓶应用程序。

不确定发生了什么变化,但是如何配置该应用程序以使更改对刷新产生影响?

我在init.py中有以下代码行:

if __name__ == '__main__':
    run_simple('0.0.0.0', 80, app, use_reloader=True, use_debugger=True)

I have a Flask App that I am running locally and testing. Every time, I make a change in the Application code, the changes would reflect on the dev environment http://127.0.0.1:8000/ with a simple browser refresh.

Now, I have to terminate the Flask App Ctrl X + Ctrl C and then reboot / relaunch the App. I am using gunicorn to launch the Flask App.

Not sure what changed, but how do I configure the App such that the changes take effect on refresh?

I have the following line of code in init.py:

if __name__ == '__main__':
    run_simple('0.0.0.0', 80, app, use_reloader=True, use_debugger=True)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋情葬爱 2025-02-04 11:38:30

当应用程序代码更改时,Gunicorn拥有自己的系统来重新加载工作流程。您可以使用 - reload cli> cli flag激活自动加载开发模式。

gunicorn --reload app:app

您可以通过 - reload-extra-file文件 arg。

Gunicorn has its own system to reload the worker process when the application code changes. You can use the --reload CLI flag to activate the auto-reloading dev mode.

gunicorn --reload app:app

You can add additional files to the watcher via the --reload-extra-file FILES arg.

流星番茄 2025-02-04 11:38:30

尝试使用枪支

if __name__ == '__main__':   
    app.run(debug=True)

web: gunicorn wsgi:app

Try

if __name__ == '__main__':   
    app.run(debug=True)

Also using Gunicorn

web: gunicorn wsgi:app
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文