简体   繁体   English

如何在 Visual Studio Code 中重新运行 Python justpy 应用程序而无需停止进程?

[英]How to rerun Python justpy apps in Visual Studio Code without having to stop the process?

I am using the Python extension in Visual Studio Code and I use the green triangle button to run Python files.我在 Visual Studio Code 中使用Python 扩展,并使用绿色三角形按钮运行 Python 文件。 在此处输入图像描述

However, that button doesn't rerun the file if the file is already running if I am working with a Flask or justpy app.但是,如果我正在使用 Flask 或 justpy 应用程序,如果文件已经在运行,则该按钮不会重新运行文件。 If the app is already running and I press the button for a second time, I get the following output in the VS Code terminal:如果应用程序已经在运行并且我第二次按下按钮,我会在 VS Code 终端中得到以下 output :

/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 "/Users/me/app/app1.py"

Instead of that I expect to get something like this:而不是我希望得到这样的东西:

/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 "/Users/me/app/app1.py"
JustPy ready to go on http://127.0.0.1:8002

PyCharm is able to rerun a running justpy app, but not VSC. PyCharm 能够重新运行正在运行的 justpy 应用程序,但不能重新运行 VSC。 Is there a setting I should maybe change in VSC?是否有我应该在 VSC 中更改的设置? Here is a sample justpy app if you want to give it a try:如果您想尝试一下,这是一个示例 justpy 应用程序:

import justpy as jp

def hello_world():
    wp = jp.WebPage()
    d = jp.Div(text='Hello world!')
    wp.add(d)
    return wp

jp.justpy(hello_world)

Edit: There is a workaround and that is to press CTRL + C or CMD + C in the terminal to stop the process and then run again, but that's just too cumbersome.编辑:有一种解决方法,即在终端中按 CTRL + C 或 CMD + C 以停止该过程然后再次运行,但这太麻烦了。

for flask apps when you set the debug=true, it will always automatically rerun on vscode when you save your file对于 flask 应用程序,当您设置 debug=true 时,它会在您保存文件时始终在 vscode 上自动重新运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM