from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'Hello, World!
' @app.route('/user/') def index(name): return ' Hello,%s!
' % name if __name__ == '__main__': app.run(debug=True)
在运行这段代码时, 报运行错误,
一直都摸不到头脑, 然后重新看了下代码, 发现函数命名重复, 将def index(name)改为def user(name)后运行就可以了.
from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'Hello, World!
' @app.route('/user/') def user(name): return ' Hello,%s!
' % name if __name__ == '__main__': app.run(debug=True)