Reputation: 27
My question is very simple, when you run this code :
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
You will see Hello World!
on 127.0.0.1:5000
But I' m trying to change like this, I took "Internal Server Error"
.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
a= 5+10
return a
if __name__ == '__main__':
app.run()
Code Source: http://flask.pocoo.org/docs/quickstart/#a-minimal-application
Upvotes: 1
Views: 88
Reputation: 816
If you are still learning Flask, it would be a good idea to enable debug mode.
app.debug = True
app.run()
Or pass it as a parameter to run:
app.run(debug=True)
This way, you'll see more than just a 500 error.
Upvotes: 1
Reputation: 27216
Your hello_world
method should return a str
or file-like object, but in this case you're returning an int
. Just cast:
@app.route('/')
def hello_world():
a = 5 + 10
return str(a)
Upvotes: 2