Python Forum

Full Version: Running simple flask - getting 404
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Have a file called hello.py saved to D: drive as below.

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World!"
Have ran pip install -U Flask from D:\python using conda prompt.

D:\Python is area we have python installed to

says successful.

In conda windows prompt
have typed
set FLASK_APP=hello
flask run

says Running on http://127.0.0.1:5000

When type http://127.0.0.1:5000 into chrome or browser gives 404 and doensn't launch browser automtically.

also tried running python flask run but still not getting output.

Ultimately looking to possibly use flask as way of deploying machine learning models and looking to see if can get hello world app running as starter for ten.

Anyone know what missing and how can achieve this?

Thanks

Found another site and tried

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
        return "Hello World!"

if __name__ == "__main__":
    app.run()
saved as hello.py
and ran python D:\hello.py

went to website and looks to work
use:
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()
Thanks for update