Use Python on MAMP

I am slowly moving from PHP to Python. In particular, when I work in webdev / webdesign, I would like to display a basic HTML page using Python using the following code:

#!/usr/bin/python

print('<html><head></head><body>This is a test</body></html>')

Again, the point is to see if it works. Sending the file online to my host as index.cgi I had no problems displaying the contents of the file. Problems arise when I try to install the WSGI module on MAMP or just so that Python works as a whole with it. When it goes to localhost / index.cgi, the contents of the file are displayed instead of its results. I followed half a dozen tutorials and no one seems to be working, I always run into a problem at some point. This is similar to the fact that Apache, which comes with MAMP, is not built in such a way that allows you to add modules to it (for example, wsgi).

This is also due to the fact that I can’t find a recent article on how to install Python on MAMP, all of them are either from 2008 or 2009, or from older versions of MAMP, Python and Macports.

Can someone point me to the current procedure to make this work?


EDIT: Well, after you found in this article, I realized that MAMP by default does not process CGI scripts outside of cgi-bin / folder in MAMP /. So I changed the conf apache file as explained, now it seems to be reading the .cgi file, but it gives a 500 error with the above content. Is the code the culprit or is it MAMP?

+5
source share
2 answers

, CGI MAMP cgi-bin/folder (. ) :

print 'Content-type: text/html\n\n'

+2

CGI, , WSGI. Python. , , script . :

#! /usr/bin/python

script Python, Python Python.

0

All Articles