为什么这段代码不在heroku上运行?(内部服务器错误)
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
a = 10
b = 20
c = a + b
return c
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
日志:
使用命令python app.py
a = 1
^
SyntaxError 启动进程:无效语法
文件“app.py”,第 8 行
此代码正在运行(heroku 指南中的 Python hello world)
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)