Python的Web框架 Bottle
jopen
13年前
<p><img alt="Python的Web框架 Bottle" src="https://simg.open-open.com/show/a01af567310600afdff651f3e2888047.png" width="200" height="69" /></p> <p>一个Python Web框架,整个框架只有一个文件,几十K,却自带了路径映射、模板、简单的数据库访问等web框架组件,确实是个可用的框架。初学web开发可以拿来玩玩,其语法简单,部署也很方便。</p> <ul class="simple"> <li><strong>Routing:</strong> Requests to function-call mapping with support for clean and dynamic URLs.</li> <li><strong>Templates:</strong> Fast and pythonic <a class="reference internal" href="/misc/goto?guid=4959499836250622894"><em>built-in template engine</em></a> and support for <a class="reference external" href="/misc/goto?guid=4958973149662264617">mako</a>, <a class="reference external" href="/misc/goto?guid=4958331400649356567">jinja2</a> and <a class="reference external" href="/misc/goto?guid=4959499836400718554">cheetah</a> templates.</li> <li><strong>Utilities:</strong> Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.</li> <li><strong>Server:</strong> Built-in HTTP development server and support for <a class="reference external" href="/misc/goto?guid=4958874018917575511">paste</a>, <a class="reference external" href="/misc/goto?guid=4959499836654276456">fapws3</a>, <a class="reference external" href="/misc/goto?guid=4959499836765206753">bjoern</a>, <a class="reference external" href="/misc/goto?guid=4959499836845469741">Google App Engine</a>, <a class="reference external" href="/misc/goto?guid=4958187576312412773">cherrypy</a> or any other <a class="reference external" href="/misc/goto?guid=4959499836950585281">WSGI</a> capable HTTP server.</li> </ul> <p></p> <p>示例代码:</p> from bottle import route, run <br /> <br /> @route('/:name') <br /> def index(name='World'): <br /> return ' <b>Hello %s!</b>' % name <br /> <br /> run(host='localhost', port=8080) <br /> <br /> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324786171264" target="_blank">http://www.open-open.com/lib/view/home/1324786171264</a></p>