What I accomplished today: running a Python script using cgi-bin that assembles a page which the server sends back, including data loaded from a file, and the result of a Python call to a
datetime.date
object.At first I turned off Airport on my laptop before enabling Web Sharing in Sharing Prefs. That was too restrictive, so later I did as suggested here, I modified the config file:
[UPDATE: Discussion on whether 127.0.0.1 can be "spoofed" and what good it would do here, here, here. Basically, no.]
But it wouldn't let me edit it at first! I didn't have the correct permissions.
The config file says:
So I changed that line to
Listen 127.0.0.1:80
I can point Safari at
http://localhost/~telliott_admin/
or http://127.0.0.1/~telliott_admin/
.That's my "personal website" which serves this page:
/Users/telliott_admin/Sites/index.html
. The page has an image
<img src="images/gradient.jpg" alt=""
height="304" width="800" border="0" />
The image is just where you'd expect it to be in
/Users/telliott_admin/Sites/images
The page also has a couple of links
<a href="/manual/">Apache manual</a>
<a href="http://www.apache.org/httpd">Apache</a>
The manual referenced by the link is actually here:
/Library/WebServer/share/httpd/manual/index.html
My "computers website" is:
http://localhost/
This page just says "It works!" It is here:
/Library/WebServer/Documents/index.html.en
So I guess when the URL ends with '/' you load the index.html page
There is also an empty directory
/Library/WebServer/CGI-Executables
, which we're going to use next.I made a file called
data.txt
on my Desktop:I made a second file with a Python script, called
script.py
:Point browser at:
http://localhost/cgi-bin/script.py
When it doesn't work, do this: