On Mon, Oct 26, 2009 at 10:00 AM, Peng Yu <pengyu...@gmail.com> wrote: > On Sun, Oct 25, 2009 at 11:09 PM, Simon Forman <sajmik...@gmail.com> wrote: >> On Sun, Oct 25, 2009 at 4:47 PM, Peng Yu <pengyu...@gmail.com> wrote: >>> Although, python can be used to provide web service. The following >>> webpage also mentioned, "Apache the best and most widely used web >>> server on the Internet today, check it out. If you want to run your >>> own web server this is the one to get, you can get binaries for both >>> Windows and Unix. You can download the entire sourcecode if you want >>> to check how it was made." Therefore, it would be better to use Apache >>> rather than python to provide web service, right? >>> >>> http://fragments.turtlemeat.com/pythonwebserver.php >> >> >> Both "best" and "better" (that website and you, respectively) omit >> mention of the criteria used for the evaluation. >> >> To determine what is "best" you must first answer "for what?" >> >> >> (Also, it is reasonable to use /both/ apache and python together, with >> mod_python or mod_wsgi, etc...) > > I have never made a web server before. So I don't know what criterion > I should use? If possible, would you please let me know what pros and > cons you can think of?
Well, criteria like, how much traffic do you need to support? How often will you be changing your code? Do you have your own server or are you using some sort of "hosting plan" with another company? Those are pretty general. I'm not a web server expert. I recently wrote a small server script. It's only job was to listen for POST requests from a third-party SVN repository service that indicated a commit had been made and then trigger a buildbot build/test cycle. For this the BaseHTTPServer module was sufficient. Apache is highly regarded, but I've heard Nginx is, or can be, faster (I don't know if that's true, but I've heard it...) Apache has a /lot/ of features and capabilities, which can mean it will have a steep learning curve (again depending on what you want to do with it.) But if you're using an OS with good package support, like Ubuntu linux, getting a basic Apache installation up and running takes one command. (And some time understanding the default configuration...) There are also options like CherryPy (http://www.cherrypy.org/) or Twisted Web (http://twistedmatrix.com/trac/) which are HTTP servers (and more) written in python. Probably the most important question to answer is, "How much do you want to learn?" > How to use apache and python together? Does each of them offer some > functions that are not available in the other? Thank you! You're welcome. :) Possibly the simplest method is to write a CGI script in python. I've already mentioned mod_python and mod_wsgi which are Apache modules that let you use python with Apache. There are also web frameworks like Django and TurboGears which can work with Apache. These options all offer different functions while providing essentially the same functionality. You'll have to do your own homework to figure out which is the best for you. Regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list