# hello.py
from flask import Flask, render_template
from flask_script import Manager
from flask.ext.bootstrap import Bootstrap
app = Flask(__name__)
manager = Manager(app)
bootstrap = Bootstrap(app)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/user/name')
def user(name):
return render_template('user.html', name=name)
if __name__ == '__main__':
manager.run()
$ python3 hello.py runserver --host 0.0.0.0
hello.py:3: ExtDeprecationWarning: Importing flask.ext.bootstrap is deprecated, use flask_bootstrap instead.
from flask.ext.bootstrap import Bootstrap
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Jul/2017 21:07:40] "GET /user/henry HTTP/1.1" 404 -
网页标题显示【404 Not Found】
网页内容为【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('/user/name')内的name应该加上<>