Categories
Uncategorized

Python and web stuff – Python

This is going to be incredibly cryptic, simply because this entry is just a quick reminder to myself.

I have installed MAMP (MacOSX, Apache, mySQL, PhP), then I made sure it was all running…

and I created a directory where all my localhost files will live…

/Documents/_localHost/

I created another dir where the python cgi will live

/Documents/_localHost/cgi-bin

and, finally I created a file named test.py with the following script

#!/usr/bin/python

print 'Content-Type: text/html'
print
print '<html>'
print '<head><title>Hello from Python</title></head>'
print '<body>'
print '<h2>Hello from Python</h2>'
print '<p>'
print '''

so now you decide to work
you big fat sack of sh!t.

'''
print '</p>'
print '</body></html>'

with changed permisions…

$ chmod 755 test.txt

Next step is to start python, like this

$ python -m CGIHTTPServer

which should return something similar to this

Serving HTTP on 0.0.0.0 port 8000 ...

so we can now access it through port 8000

http://localhost:8000/cgi-bin/test.py

…DONE!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s