error 方法
使用 error 方法可以重写 404 页面。
from bottle import error
@error(404)
def error404(error):
return 'Nothing here, sorry'abort
返回某个 HTTP 状态码。
from bottle import abort
@route('/restricted')
def restricted():
abort(401, "Sorry, access denied.")redirect
URL 重定向
@route('/wrong/url')
def wrong():
redirect("/right/url")