Re: python web service or Apache?

2009-10-26 Thread Peng Yu
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?

How to use apache and python together? Does each of them offer some
functions that are not available in the other? Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python web service or Apache?

2009-10-26 Thread Simon Forman
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


Re: python web service or Apache?

2009-10-26 Thread rurpy
On 10/26/2009 08:00 AM, Peng Yu 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?

Apache requires root access to the server machine, is quite complex
and requires some learning and work to setup and use.
On the other hand it is very powerful, will handle high traffic,
and can handle the requirements of most any web site, so even if
you start with a simple site you can be pretty sure it will handle
your needs in the future as your web site grows.  Because Apache
is widely used, there an many places and people that can provide
help and advice on how to run it.

A small simple custom web server built with Python will likely
only work well with a very small traffic volume and will have
very limited capabilities but is very quick to get up and running.
You can run it on a non-privileged port if you do not have
root access to your server machine.

 How to use apache and python together? Does each of them offer some
 functions that are not available in the other? Thank you!

Apache, like most general purpose web servers, supports the CGI
protocol.  You can setup Apache so that when a request is made
for a file ending with .py, it will run the python file and
send the program's output to the client browser.  This allows
you to generate html output from the Python program.  Python's
standard lib contains the cgi module that will help in writing
python code for this.

There are other more efficient ways of using Python with
a web server such as mod_python, or wsgi, but cgi is probably
the simplest, and has the most how-to info available.

HTH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python web service or Apache?

2009-10-26 Thread Paul Rubin
ru...@yahoo.com writes:
 Apache requires root access to the server machine,

Only to access the privileged ports.

 A small simple custom web server built with Python will likely...
 You can run it on a non-privileged port if you do not have
 root access to your server machine.

You can do that with apache as well.  Which is more complicated is a
little bit subjective.  I use both, and for something simple I
generally find it easier to throw together a custom server with
SocketServer.py, but it takes some familiarity with Python networking
to be able to do that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python web service or Apache?

2009-10-26 Thread Gabriel Genellina

En Sun, 25 Oct 2009 17:47:43 -0300, Peng Yu pengyu...@gmail.com escribió:


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?


Note that web server != web service.

Apache is a web server; it handles HTTP requests to serve web pages,  
typically HTML documents, images, videos, etc. Usually those requests come  
from a human browsing the web. Apache is highly optimized to serve  
static documents (those that are already prebuilt, and aren't dependent  
on specific details of the current request, e.g. a photo).
dynamic documents (e.g. your bank account statement) have to be  
generated for each specific request - there is a program behind those  
dynamic documents, and that program may be written in Python (or Perl, or  
PHP, or whatever). That is, Python is used to build dynamic content --  
pages that cannot be prebuilt.


Although you can write a web server in Python itself, and it works fine  
for low-volume sites, it cannot compete (in speed, number of concurrent  
transactions, and other features) with Apache or lighttpd.


A web service is a program that exposes some sort of API that can be  
accessed thru a web interfase, mostly intended to be used by other  
programs, not humans. Web services usually are built on top of HTTP as the  
transport layer, so they run behind Apache or other web server. Python is  
perfectly adequate to write web services.


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


python web service or Apache?

2009-10-25 Thread Peng Yu
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python web service or Apache?

2009-10-25 Thread Simon Forman
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...)


Regards,
~Simon
-- 
http://mail.python.org/mailman/listinfo/python-list