Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

flask

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?

like image 881
kayak Avatar asked May 21 '17 21:05

kayak


People also ask

How do I change my flask app?

Find the DEFAULT_PORT field. it is equal to 8000 by default. Change it to whatever you like DEFAULT_PORT = "8080" Restart your server: python manage.py runserver and see that it uses your set port number.

How do I run a flask app locally?

To run the application, use the flask command or python -m flask . You need to tell the Flask where your application is with the --app option. As a shortcut, if the file is named app.py or wsgi.py , you don't have to use --app . See Command Line Interface for more details.

How do you refresh a flask template?

Flask does not reload the template when it is changed. After you change a template, you need to reload the web app for it to get the new template.


1 Answers

Just clear the cache in your browser and try running it again.

Here's how to clear your cache in some browsers:

Firefix->https://support.mozilla.org/en-US/kb/how-clear-firefox-cache Chrome->https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en

like image 121
Golovkin Avatar answered Oct 15 '22 00:10

Golovkin