【发布时间】:2016-06-09 07:38:31
【问题描述】:
为什么我的添加功能不起作用?
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def index(name="Mona"):
#name= request.args.get('name', name)
return "Hello from {}".format(name)
@app.route('/add/num1/num2')
def add(num1, num2):
return '{} + {} = {}'.format(num1, num2, num1 + num2)
app.run(debug=True, port=8002, host='0.0.0.0')
当我浏览到 0.0.0.0:8002/add/1/4 时出现此错误
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
【问题讨论】:
-
要访问 @app.route('/add/num1/num2') 你需要浏览到 0.0.0.0:8002/add/num1/num2
标签: python python-3.x flask