Search code examples
pythonmamp

Python with MAMP not working


I'm in the process of switching from PHP over to Python.

The web project I'm on is very very small (probably just two to three script files) so I would prefer to avoid any framework and just work with Python.

I'm running MAMP (not the Pro version) on OS X Yosemite.

My python test file works fine when executed in the terminal. But when I open it in the browser, it just shows the text connect of the file, not the output.

PyTest.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

# enable debugging

import cgitb
cgitb.enable()

print 'Content-Type: text/plain'
print
print 'Hello, World!'

I'm really new to Python. What am I missing? Thanks!


Solution

  • I realized that I did not completely understand the way Python and Webservers interact and why it wouldn't work with MAMP out of the box.

    I'm now using a lightweight web framework (bottle) which has a small development server built in.

    The website later will be deployed using NGINX and uWSGI.