Bottle.py error routing

前端 未结 3 951
再見小時候
再見小時候 2021-02-13 03:46

Bottle.py ships with an import to handle throwing HTTPErrors and route to a function.

Firstly, the documentation claims I can (and so do several examples):



        
3条回答
  •  旧巷少年郎
    2021-02-13 04:37

    This works for me:

    from bottle import error, run, route, abort
    
    @error(500)
    def custom500(error):
        return 'my custom message'
    
    @route("/")
    def index():
        abort("Boo!")
    
    run()
    

提交回复
热议问题