Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : I can't run python scripts



Normal Mode | Print  

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi December 27, 2012, 1:57 pm
Didn't understand what you meant here.

This is my test.py which is in C:\Program Files\Ampps\www\myapp\test.py and I get the same text if open the browser at localhost/myapp/test.py
Quote
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"



Content of C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi is the same, I didn't changed it after first creating the file and pasting the code
Quote
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]



What is the output of http://localhost/myapp ?

BTW Python scripts doesn't work like PHP here.

In virtualhost when we configure
Code
WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"
http://localhost/myapp becomes the alias to myapp.wsgi. Hope you get it now. :)

Also the below code won't work... here you here using directly the CGI(not mod_wsgi). :)

Instead of below code,
Code
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


write the following code.
Code
#!"C:\Program Files\Ampps\python\python.exe"
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


Before you run test.py, Go to AMPPS Application -> Apache Tab -> Configuration Tab. Find Line
Code
AddHandler cgi-script .cgi .pl
change it to
Code
AddHandler cgi-script .cgi .pl .py
Save the File. Restart Apache.
Copy test.py and paste it to C:\Program Files\Ampps\www\cgi-bin\test.py and
access http://localhost/cgi-bin/test.py

Edited by tidus : December 27, 2012, 2:23 pm

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   


Threads
 muotaz   I can't run python scripts (25 Replies, Read 46659 times)
    |--  tidus   Hi, For running...   on November 23, 2012, 5:42 am
    |--  memzxi   Hi. Another newbie...   on December 26, 2012, 8:04 pm
    |--  tidus   Hi. Another newbie...   on December 27, 2012, 7:46 am
    |--  memzxi   Didn't work. Ended...   on December 27, 2012, 1:13 pm
    |--  tidus    After that, I...   on December 27, 2012, 1:23 pm
    |--  memzxi   Didn't understand what...   on December 27, 2012, 1:57 pm
    |--  tidus   Didn't understand what...   on December 27, 2012, 2:22 pm
    |--  memzxi   I installed AMPPS...   on December 30, 2012, 9:23 pm
    |--  tidus   Hi, To start...   on December 31, 2012, 7:46 am
    |--  memzxi   I thought CGI...   on January 12, 2013, 5:32 pm
    |--  tidus   Hi, Copy the...   on January 15, 2013, 5:09 am
    |--  tidus   Hi, To install...   on January 15, 2013, 5:41 am
    |--  memzxi   Hi, Copy the...   on January 21, 2013, 12:52 pm
    |--  tidus   Hi, And did...   on January 21, 2013, 5:39 pm
    |--  memzxi   It's not about...   on January 21, 2013, 5:41 pm
    |--  tidus   Hi, Just checked...   on January 21, 2013, 6:30 pm
    |--  memzxi   Hmz, maybe I...   on January 21, 2013, 6:35 pm
    |--  tidus   Hmz, maybe I...   on January 21, 2013, 6:36 pm
    |--  chrisjensen23   OK, so I...   on March 26, 2014, 4:07 pm
    |--  chiffenok   Hi, everybody. Finally...   on July 22, 2014, 3:56 pm
    |--  tidus   Hi, The folder...   on July 23, 2014, 7:27 am
    |--  shovan   I followed instruction...   on October 1, 2014, 1:29 pm
    |--  Akirami   OK, so I...   on December 8, 2014, 12:09 pm
    |--  Perd01   This thread gave...   on July 9, 2016, 9:29 pm
    |--  KenScape   Perd01: I wonder...   on August 27, 2016, 8:05 pm

« Previous    Next »

Normal Mode | Print  



Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is July 4, 2025, 10:24 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 10  |  Page Created In:0.012