views:

239

answers:

5

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

  1. Embed a web server to let the 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.

A: 

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.

Ritesh M Nayak
I have many specific requirements for the tool, so ...
zhongshu
I would *still* back Ritesh's recommendation and ask you to consider using something like CruiseControl or BuildBot (if you prefer Python) and extend it rather than build something up from scratch. I did that once and I can tell you it quickly gets out of control.
Noufal Ibrahim
Ok, I edit my question, just a general question for python web server. ;)
zhongshu
+3  A: 

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

Noam
How about XML-RPC? can I use the internal web server for XML-RPC and the static files at the same port?
zhongshu
not as far as i know.interestingly, i have done such a project, and just instantiated 2 servers, one for http, the other for XML/RPC
Noam
+1  A: 

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.

Florian Lagg
A: 

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.

S.Lott
Thanks, I will check the wsgiref, and for the background job, I don't mean an external process, it is just something like check email periodically, so I don't need subprocess.
zhongshu
A: 

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.

frunsi
Really? You think it's best to re-implement it from scratch when there are multiple good solutions already in place?
JasonFruit