Built a new Flask app -- old one still showing in browser

Viewed 4083

I made the following file yesterday.

# import flask
from flask import Flask
from flask import render_template
from flask import request

app = Flask(__name__)

# create url & function mapping for root or /
@app.route('/')
def index():
    return "Hello from Flask"

# create another mapping name /hello
@app.route('/hello')
def hello():
    myName = "kayak"
    return "Hello again !!" + myName

# create mapping for /myprofile
@app.route('/myprofile')
def showmyprofile():
    return render_template('myprofile.html')

# create mapping for /myprofile
@app.route('/addprofileform')
def addprofileform():
    return render_template('myprofileform.html')

# create a mapping for /addprofile
@app.route('/addprofile')
def addprofile():
    myname = request.args.get('myname')
    state_of_residence = request.args.get('state_of_residence')
    return render_template('myprofile.html', html_page_name=myname,
    html_page_state_of_residence=state_of_residence)

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

Then I made the following file today.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'This is the homepage'

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

I thought

app.run(debug=True)

would work to clear the old data, but I doesn't and http://127.0.0.1:5000/ page keeps showing "Hello from Flask".

How do I fix this?

3 Answers

You can export the FLASK_ENV environment variable and set it to development before running the server

export FLASK_ENV=development

flask run

This worked for me.

Related