首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web.py札记 处理404 500

2012-09-06 
web.py笔记 处理404 500??官方cookbook ? ?http://webpy.org/cookbook/custom_notfound.zh-cn???import we

web.py笔记 处理404 500

?

?官方cookbook ? ?http://webpy.org/cookbook/custom_notfound.zh-cn

?

?

?

import web        urls = (    #'/(hello)', 'hello'    #test for notfound     '/hello', 'hello'      #test for internalerror)class hello:            def GET(self, name):        if not name:             name = 'World'        return 'Hello, ' + name + '!'def notfound():    return web.notfound("Sorry, the page you were looking for was not found.")    # You can use template result like below, either is ok:    #return web.notfound(render.notfound())    #return web.notfound(str(render.notfound()))def internalerror():    return web.internalerror("Bad, bad server. No donut for you.")if __name__ == "__main__":    app = web.application(urls, globals())    app.notfound = notfound    app.internalerror = internalerror    app.run()

?

?

感觉这个很好用啊

?

为什么越学越觉得java很笨重?

?

?

?

?

?

热点排行