Ripple-Python的一个meta web 框架

网友投稿 590 2022-10-20

Ripple-python的一个meta web 框架

Ripple-Python的一个meta web 框架

ripple: a meta web framework for python

ripple lets you write webi, applications. webi is wsgi rearranged. It is a collection of webi middlewares, utilities and web server adaptors.

ripple takes everything it can from clojure's ring, perl's plack, python's werkezeug and ruby's rack.

installing ripple

pip install webi-ripple

running webi applications

Currently there are no direct interfaces to webservers. But you can use wsgi adaptor to convert webi applications to wsgi and run them with any wsgi compliant container.

Following example runs a sample app with werkezeug wsgi server.

def hello(environ): return 200, {'Content-Type': 'text/html'}, '

Hello, from Ripple.

'if __name__ == '__main__': import ripple.adaptors from werkzeug.serving import run_simple run_simple('localhost', 4000, ripple.adaptors.wsgi(hello), use_debugger=True, use_reloader=True)

adding features using middlewares

Additional capabilities can be added to webi applications using included and contributed middlewares. A middleware takes a webi application, wraps additional functionality and returns a webi application.

Following example shows, how a webi can serve a file as a response body.

from ripple.middlewares import file_infoimport ripple.adaptorsdef file(environ): return 200, {}, open('ripple.png', 'rb')app = ripple.adaptors.wsgi(file_info(file))

composing a webi app

ripple provides builder, a helper function to compose middlewares for application. It can be used as a following.

from ripple import builderimport ripple.middlewaresdef basic(environ): return 200, {'Content-Type': 'text/plain'}, 'a composed app'app = builder(basic, ripple.middlewares.params, ripple.middlewares.file_info, ripple.middlewares.static)

TODO

securing session cookies.write tests.start documenting usage.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:HDU 1395 2^x mod n = 1(暴力枚举)
下一篇:Pure.IoC- 自动依赖注入框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~