Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running simple flask - getting 404
#1
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
Reply
#2
use:
from flask import Flask
app = Flask(__name__)

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

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


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Running Gunicorn with flask.... SpongeB0B 1 1,588 Jun-27-2022, 03:09 PM
Last Post: SpongeB0B
Question running Flask with waitress having web traffic log... SpongeB0B 2 5,788 May-06-2021, 07:07 AM
Last Post: SpongeB0B
  Flask Ubuntu Server Not Running Wheel 0 1,977 Jul-14-2020, 08:12 PM
Last Post: Wheel
  Build a simple Webapp with Python Flask and mariaDB newbie1 3 3,317 Jun-04-2020, 09:34 PM
Last Post: lmolter54
  Running Flask web on other IP than 127.0.0.1 popolon59 1 2,092 Mar-29-2020, 10:02 AM
Last Post: Larz60+
  Simple flask rest api problem cancerboi 4 2,782 Jan-29-2020, 03:10 PM
Last Post: brighteningeyes
  Flask not running python interpreter from virtual env Charles1 1 2,230 Nov-22-2019, 05:09 PM
Last Post: Larz60+
  Running flask run produces error. Charles1 1 4,028 Oct-04-2019, 10:38 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020