使用烧瓶时出现404找不到错误 [英] 404 Not found error while using flask
本文介绍了使用烧瓶时出现404找不到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用烧瓶学习python中的Web开发.该代码没有显示任何错误,但是当我运行它时,浏览器显示错误-找不到404.代码:
I'm learning web development in python with the flask. The code doesn't show any error, but when I run it, the browser shows Error - 404 Not Found. Code:
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/admin/')
def hello_admin():
return 'Hello Admin'
@app.route('/guest/<guest>')
def hello_guest(guest):
return 'Hello %s as Guest' % guest
@app.route('/user/<name>')
def hello_user(name):
if name =='admin':
return redirect(url_for('hello_admin'))
else:
return redirect(url_for('hello_guest',guest = name))
if __name__ == '__main__':
app.run(debug=True)
Chrome中的输出:未找到在服务器上找不到请求的URL.如果您手动输入网址,请检查拼写,然后重试
Output in Chrome: Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again
推荐答案
查看全文