-2

I am using the Python extension in Visual Studio Code and I use the green triangle button to run Python files. enter image description here

However, that button doesn't rerun the file if the file is already running if I am working with a Flask or justpy app. 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:

/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. Is there a setting I should maybe change in VSC? Here is a sample justpy app if you want to give it a try:

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.

multigoodverse
  • 7,638
  • 19
  • 64
  • 106
  • In VS Code, we use the command "_python -m flask run_" to execute flask or click _F5_ to debug it, and the run button provided by the "Python" extension is to execute "Run Python file in Terminal". – Jill Cheng Apr 08 '21 at 05:11

1 Answers1

0

for flask apps when you set the debug=true, it will always automatically rerun on vscode when you save your file