I have a simple Flask server:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
When I run $ curl http://127.0.0.1:5000/ on the command line, I get the error
curl: (7) Failed to connect to 127.0.0.1 port 5000: Connection refused
What is the problem?
If the code snippet above is exactly the same to your code that you are trying to run then you are missing app.run() statement: Also You can specify any port number with port=<port_number> parameter in app.run()
Try this:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(debug=True)
and then run this script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With