2

XAMPP-PYTHON-WINDOWS

I have installed Xampp. I'm running the apache web server and mySql service. I want to host my python code on my web server. However, I am having a hard time setting up python with Xampp. I read about modwsgi, downloaded it and pasted it in the modules folder. I have python 3.2 installed on my C drive.

Please let me know what should I do next, as in where should i paste my python files and how should I execute them through a web browser? I should be able to do this:

http://74.xxx.xxx.xx/python/test.py (localhost/python/test.py)

and this should execute the python code.

When I try to do the above, i get this:


Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500

74.194.129.16 3/2/2011 2:11:16 AM Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1


All the help is highly appreciated.

csguy11
  • 5,007
  • 6
  • 22
  • 20

2 Answers2

4

The official releases of mod_wsgi don't support Python 3.2 so you cant use it. To use Python 3.2 you would need to compile mod_wsgi from source code in subversion repository which I would suggest is probably going to be a bit beyond what you are able to do based on problems you are having above. So, use Python 2.6/2.7. Also see:

http://code.google.com/p/modwsgi/wiki/InstallationOnWindows http://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2#Windows_Binary_Downloads

As Daniel suggested I would suggest you use Flask. You could also use web2py which is another framework which is easy for newbies. I would also suggest that if you are only starting to learn this stuff that you not use Apache/mod_wsgi and instead just use the inbuilt development server provided by the Python web framework you use. That will save you a lot of headaches initially if you know nothing about Apache.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
0

mod_wsgi doesn't run Python scripts like that. It's a method of hosting long-running Python applications in separate processes, which are dispatched to by Apache. And anyway, you don't just install Apache modules by "pasting" them into a folder.

If you just want to run Python scripts by giving their path to Apache, which by the way is a pretty horrible way to do it, you just want to configure Apache so that it treats Python scripts as CGI. There's plenty of documentation on how to do this.

But a much better way is to serve your code is by writing a proper WSGI service, probably by using one of the many minimal frameworks around - my favourite is Flask.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • 3
    Sorry Daniel, you are actually wrong on a few accounts. Apache/mod_wsgi can be configured to map URLs to scripts like that. Ie., just like you can throw CGI scripts in a directory and then reference them via a URL where script name is in the URL, you can do the same with mod_wsgi if configured appropriately. Only difference to CGI is that code then stays persistent. Next is that the default mode (and only mode on Windows) has code run in Apache processes and not as a separate process. The daemon mode is only available on UNIX and has to be configured to be used. – Graham Dumpleton Mar 02 '11 at 21:56