0

At the first time when I'm running the below code in Python, it's succesfully running in localhost by displaying hello, I'm using the atom editor.

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_wrld():
   return "hello"

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

But when I'm changing my return to hello python as follows:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def dhineTrend():
   return "hello python"

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

It's running in localhost but when I'm hitting the browser it keep on showing old hello. How to overcome it?

Note: After first run I cut the run, then only request the second.

franklinsijo
  • 17,784
  • 4
  • 45
  • 63

1 Answers1

3

Enable DEBUG to auto reload files on change,

app = Flask(__name__)
app.debug = True

There are multiple ways to do this,

app.config.update(DEBUG=True)

Or

app.config['DEBUG'] = True

Or, Create a config.py defining all the Flask settings

app.config.from_object('config')
franklinsijo
  • 17,784
  • 4
  • 45
  • 63