开发者

Python web server?

I want to develop a tool for my project using python. The requirements are:

  1. Embed a web server to let the 开发者_JAVA技巧user get some static files, but the traffic is not very high.
  2. User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?
  3. Besides the web server, the tool need some background job to do, so these jobs need to be done with the web server.

So, Which python web server is best choice? I am looking at CherryPy, If you have other recommendation, please write it here.


what about the internal python webserver ? just type "python web server" in google, and host the 1st result...


Well, I used web frameworks like TurboGears, my current projects are based on Pylons. The last ist fairly easy to learn and both come with CherryPy.

To do some background job you could implement that in pylons too.

Just go to your config/environment.py and see that example: (I implemented a queue here)

from faxserver.lib.myQueue import start_queue
...
def load_environment(global_conf, app_conf):
    ...
    start_queue()

It depends on your need if you simply use CherryPy or start to use something more complete like Pylons.


Use the WSGI Reference Implementation wsgiref already provided with Python

Use REST protocols with JSON (not XML-RPC). It's simpler and faster than XML.

Background jobs are started with subprocess.


Why dont you use open source build tools (continuous integration tools) like Cruise. Most of them come with a web server/xml interface and sometimes with fancy reports as well.


This sounds like a fun project. So, why don't write your own HTTP server? Its not so complicated after all, HTTP is a well-known and easy to implement protocol and you'll gain a lot of new knowledge!

Check documentation or manual pages (whatever you prefer) of socket(), bind(), listen(), accept() and so on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜