如何在创建迁移时阻止烧瓶运行我的服务器?(How to stop flask from running my server when creating migrations?)

编程入门 行业动态 更新时间:2024-10-24 02:29:08
如何在创建迁移时阻止烧瓶运行我的服务器?(How to stop flask from running my server when creating migrations?)

每当我使用flask-migrate框架运行诸如flask db migrate或flask db upgrade类的命令时,它总是开始在localhost上运行我的应用程序,并且在允许服务器停止并生成迁移之前我必须按CTRL+C退出。 我怎么能避免这个?

我遇到的另一个问题是,每当我运行时,它将首先在调试模式下运行,在点击CTRL+C退出后,它将再次运行而不启用调试模式,在另一个端口上运行。 我怎么只限制与前者一起跑步? 谢谢。

Whenever I run a command like flask db migrate or flask db upgrade using the flask-migrate framework, it always starts running my application on localhost, and I have to press CTRL+C to quit before allowing the server to stop and generate the migration. How can I avoid this?

Another question I have is whenever I run, it will first run it in debug mode and after hitting CTRL+C to quit it will again run without debug mode on, on a different port. How do I only limit to running with the former? Thanks.

最满意答案

您的应用程序中的某个位置有app.run()调用。 Flask运行您的应用程序本身,这个额外的调用是导致db命令在执行命令之前运行服务器的调用,并且还导致服务器在执行flask run时运行两次。 如果您发现并删除此行,我认为您会没事的。

Somewhere within your application you have a app.run() call. Flask runs your application itself, this extra call is the one that is causing the db commands to run the server before carrying out the command, and also causes the server to run twice when you do flask run. If you find that and remove this line I think you will be fine.

更多推荐

本文发布于:2023-08-07 22:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466417.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:烧瓶   服务器   如何在   stop   flask

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!