Ask coding questions

← Back to all posts
Python Flask problem
h
IcynDevz (765)

Python Flask problem

Here's my code:

from flask import Flask

app = Flask(__name__)

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

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

I thought when you run this it should have a new tab window and return 'hello'. But when I ran the code, all it did was show this:

 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 172-357-633

And it didn't have a new tab window. Don't judge me please, I'm still a noob at flask. So yeah.

Answered by SixBeeps (5061) [earned 5 cycles]
View Answer
Comments
hotnewtop
SixBeeps (5061)

Replit requires that you run servers on the host 0.0.0.0, so replace the app.run() call with this:

app.run(host="0.0.0.0", debug=True)
ch1ck3n (1625)

can you make the repl public?