Python & XAMPP on Windows: how to?

前端 未结 2 771
太阳男子
太阳男子 2020-12-23 18:36

I have installed on my Win7x64 Xampp and Python 2.7.

Now I\'m trying to get the \"power\" of Python language... how can I do it?

I\'ve tried with mod_python

2条回答
  •  [愿得一人]
    2020-12-23 18:59

    WSGI is a lot better, but at least I googled and tried to set it up for days without success. CGI is less efficient, but as most people use windows for development only, it makes little/no difference. It's super easy to set up!

    CGI method:

    1. In xampp\apache\conf\httpd.conf look for this line: AddHandler cgi-script .cgi .pl .asp. Modify it so it looks like this: AddHandler cgi-script .cgi .pl .asp .py
    2. At the top of each Python script you create, set the path to your version of Python. For instance, if yours is in C:\Python27 write: #!/Python27/python
    3. Put test sample test code in xampp\cgi-bin and access localhost/cgi-bin/your-file.py

    sample test code(change commented python path according where you have it installed):

    #!C:/Python27/python
    
    print "Content-type: text/html\n\n"
    print "Hello World from PythonHello World from a Python CGI Script"
    

    I've tested this in xampp 1.8.1 if something doesn't work read tihs:

    source: http://elvenware.com/charlie/development/web/Python/Xampp.html

提交回复
热议问题