带瓶子的蟒蛇网
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带瓶子的蟒蛇网相关的知识,希望对你有一定的参考价值。
**work in progress**
#!/usr/bin/python # -*- coding: utf-8 -*- import os import bottle as web # http://bottle.paws.de/page/docs DEV=True web.debug(DEV) @web.route("/static/:path") def static(path): web.send_file(path,root="static") @web.route('/:name#.*#') def index(name): name = name or "unknown" web.response.COOKIES['kiki'] = name return """hello %(name)s <a href='/do/show?a=1&a=2'>show</a>""" % locals() @web.route('/do/:cmd?') def cmd(cmd): if cmd=="show": yield "<li>cookies : %s</li>"% str(web.request.COOKIES) yield "<li>get : %s</li>"% str(web.request.GET) yield "<li>post : %s</li>"% str(web.request.POST) else: web.redirect("/") #don't work with yield now ;-( @web.route('/.*') def fallback(): yield "my 404" #~ web.abort(404, "Not Found") @web.error(500) # don't work for me ?!? def fallback500(err): return "my error:"+str(err) def main(useGae=False): if useGae: from google.appengine.ext.webapp import util util.run_wsgi_app(web.default_app()) else: web.run(reloader=DEV) if __name__=="__main__": main()
以上是关于带瓶子的蟒蛇网的主要内容,如果未能解决你的问题,请参考以下文章