《Flask Web开发》学习笔记之bug--(1)【404 Not Found】

本文记录了在学习《Flask Web开发》过程中遇到的一个404 Not Found错误。问题源于@app.route('/user/name')定义中,name参数应被包含在<>内,以正确匹配URL。通过修正此细节,成功解决了页面找不到的问题。

# 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应该加上<>




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值