0

I am trying to develop a simple webpage using the Spyder IDE and Flask. I created the standard 'hello world' page.

From within Spyder I ran the script which I also tried running from the Windows Command Prompt/ Using the command python main.py I was able to launch my hello world webpage in http://127.0.0.1:5000/

I've gone back and updated the file to change the display text. Saved the file, restarted the code and the same content appears.

I have cleared the cache from the chrome browser I am already using. I have opened this same address in other browsers (firefox and IE). I created another version of this file in a different folder and also launched it.

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello, World! anyone?"

@app.route("/page2")
def salvador():
    return "Hello, there"

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

No matter what I do, I get the same original hello world webpage.

Peej1226
  • 132
  • 12
  • Restarted the code where? Why is Spyder relevant here? Are you running it in the IDE? – roganjosh Aug 28 '19 at 20:16
  • Did you stop the previous process though?It might be running as a background process – mad_ Aug 28 '19 at 20:16
  • 1
    If you have launched the process first in Spyder then you'll need to ctrl C in the Spyder console or restart IPython. Really, don't run the Flask dev server through Spyder, ever, it'll drive you nuts. Code in it, just never click "run" :) you should have seen a "port in use" error, though if you have done that... – roganjosh Aug 28 '19 at 20:17
  • @roganjosh this is exactly what I did [I will update the question after I comment], but everything looks to have stopped. Clicking the red stop square didn't seem to do anything. But I've restarted Spyder and it does not appear that the process is running. How do I stop this process? it seems mad_ suggested this too, but I'm new to this so, I'll continue searching. – Peej1226 Aug 28 '19 at 20:37
  • @mad_ it does seem that I have a background process running, how do I confirm and resolve this? – Peej1226 Aug 28 '19 at 20:45
  • Try gettting the pid for the process using `netstat -a -n -o | find "5000" `then kill it `taskkill /PID /F` – mad_ Aug 28 '19 at 20:49
  • @mad_ Sorry, that's a bit over my head. I'm still new to this type of work. But your suggestion led me to finding this webpage https://github.com/plotly/dash/issues/108 where someone had a similar issue and found the issue resolved by killing (End Task) the python processes seen in Windows Task Manager. I did this, went back to Windows Command Prompt and ran my file and the updates are seen. – Peej1226 Aug 28 '19 at 20:58
  • @roganjosh What I've found allows me to launch my code is to navigate within the Command Prompt to C:\Users\XXXX\testpageagain> where I have my test main1.py here I type "python main1.py" Is this the best way to do this? – Peej1226 Aug 28 '19 at 21:01
  • Navigate to that folder normally. Hold down SHIFT and right click --> "open command prompt window here" --> type `set FLASK_APP=main1.py` then `set FLASK_DEBUG=1` then `flask run` – roganjosh Aug 28 '19 at 21:07

0 Answers0