: "404 찾을 수 없음 오류"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bottle import Bottle, run, static_file, view, template, \
get, post, request, debug
from bottle import route, response, error
import json
app = Bottle()
#class JSONErrorBottle(bottle.Bottle): ### just an not working alternative!?
class JSONErrorBottle(Bottle):
def default_error_handler(app, res):
bottle.response.content_type = 'application/json'
print("XXXXXXX " + json.dumps(dict(error=res.body, status_code=res.status_code)))
return json.dumps(dict(error=res.body, status_code=res.status_code))
app.install(JSONErrorBottle)
def main():
app.run(host = prefs['server'], port = prefs['port'], reloader=False)
if __name__ == '__main__':
rcode = main()
는 'default_error_handler가'와, 단지 표준 병 HTML 오류 페이지 호출되지 잘못된 페이지를 호출 그리고 장식품을 @bottle.error()
그냥 사용하지 않는 이유는 무엇입니까? 오류 값을 입력합니다.이 값은 bottle.abort
을 통해 전송하는 모든 개체가 될 수 있습니다. 어쨌든 당신이 원하는 기능으로 마무리 할 수 있습니다.