views:

725

answers:

6

Can I write web application that I can host on Windows(IIS web server) and Linux (Apache or lighttpd) without any changes?

CGI? Maybe something new? WSGI | FastCGI ?

+2  A: 

web.py includes a server... It will do the trick for small jobs.

By the way, Apache works on windows.

poulejapon
+7  A: 

Yes you can. But you can also use apache on windows. If you go the IIS way there's only CGI and it's pretty hard to set up. You can also use python based server like CherryPy which is pretty good and will work on all platforms with python.

Some frameworks like django support both CGI and WSGI, so you don't have to worry about the details of WSGI or CGI much.

If you ask me, WSGI is the future for python web apps.

Vasil
+1 for WSGI, but it's perfectly easy to set up CGI-to-WSGI (using wsgiref) under IIS; there is also ISAPI_WSGI for better performance, although the setup is a bit more involved.
bobince
+1 for WSGI and also there is CGI/FCGI to WSGI wrappers out there.
David
+1 for WSGI although IIS7 now supports FCGI that is pretty easy to set-up.
Frozenskys
+2  A: 

Yes, if you use CGI, FastCGI or depending on your framework, even a self-contained web server (so IIS and Apache would be a reverse-proxy) then that would all work.

The difference will be the configuration of the OS-specific servers, and also your Python environment on each OS. So you may find yourself doing a small bit of work at the beginning to make sure your paths are right, etc.

jhs
+2  A: 

A rather big Python based web framework is ZOPE.

Zope is an open source application server for building content management systems, intranets, portals, and custom applications. The Zope community consists of hundreds of companies and thousands of developers all over the world, working on building the platform and Zope applications. Zope is written in Python, a highly-productive, object-oriented scripting language

ZOPE is available on Linux and Windows, and you can use Python to write your Zope Web Apps (it includes a simpler templating system, too).

gimel
I'm not really sure you should recommend zope to a newcomer to python web development. Zope's template system is simpler than which other template system? Template systems are the apendix of modern python frameworks, usually you can choose whichever you want to use without much effort.
Vasil
Agreed, Zope should not be considered simple. Just a mention of a portable python web framework.
gimel
A: 

consider also the possibility of using web2Py, or XML-RPC implementation, or Twisted...

DrFalk3n
A: 

Writing python web apps is a topic on itself, but I would say that by default, it will be portable on multiple servers / platforms.

When developping python web applications, you will often use frameworks that provide their own web server. For performance reasons, you might want to place it behind apache, but it is not even necessary, however, you might get a performance boost by placing it behind an apache server.

Some of the most popular frameworks for web python are : Plone, Zope, CherryPy and TurboGears, only to name a few.

Under apache, you could also use python server pages through mod_python, and since apache runs on windows too, this would aslo be portable.

Martin