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

 
                   
                   
                   
                   本文记录了在学习《Flask Web开发》过程中遇到的一个404 Not Found错误。问题源于@app.route('/user/name')定义中,name参数应被包含在<>内,以正确匹配URL。通过修正此细节,成功解决了页面找不到的问题。
本文记录了在学习《Flask Web开发》过程中遇到的一个404 Not Found错误。问题源于@app.route('/user/name')定义中,name参数应被包含在<>内,以正确匹配URL。通过修正此细节,成功解决了页面找不到的问题。
           最低0.47元/天 解锁文章
最低0.47元/天 解锁文章
                           
                       
       
           
                 
                 
                 
                 
                 
                
               
                 
                 
                 
                 
                
               
                 
                 扫一扫
扫一扫
                     
              
             
                   5817
					5817
					
 被折叠的  条评论
		 为什么被折叠?
被折叠的  条评论
		 为什么被折叠?
		 
		  到【灌水乐园】发言
到【灌水乐园】发言                                
		 
		 
    
   
    
   
             
            


 
            