I'm just learning about using cgi in html files. I've read a lot of stuff on the web, but most of it is all about the trees and not enough about the forest. I'm a top-down learner and I'm having trouble understanding what's going on with cgi, apache, and html. At the moment I'm using python as my cgi scripting language, but if you'd care to answer using perl, I can handle that. Here's a MWE for a failed test I ran.HTML: (file is getname.html)<html><head></head><body><form method=POST action=./test.py>  <p>Your First Name: <input type=text name=firstname>  <p>Click here to submit form: <input type=submit value=Submit>  <input type=hidden name=session value=1f9a2></form></body></html>  Python: (file is test.py)#!/usr/bin/pythonimport sys, os, os.path, shutil, string, fileinputimport cgi, cgitbprint Content-type: text/html\nform = cgi.FieldStorage()f = open('./testOutput', 'w')if form.has_key(firstname):    f.write(form[firstname])else:    f.write(Failure)f.close()So, it looks like what's happening is that the info the user enters into the form is put into a variable called 'firstname' (actually it's a key-value pair put into a hash-like thing in the scripting language. In python it's a dictionary). This variable is then sent as input to the cgi script (test.py), and the script is run.But, that isn't what's happening. When I hit the 'Submit' button in the html file, the test.py script is displayed in the browser and the script isn't run. BTW, the reason that I have the script write to a file is so I can see whether it gets run. When I run test.py from the command line, it works fine.The fact that test.py is displayed in my browser indicates, I think, that apache isn't running or is misconfigured or has permission problems. As far as I can see, none of those things is true, but I could be wrong. So here are my questions:   1) why is apache involved at all? Is it needed to send the variables gathered in the html form to the script? If so, why? I know that html is just a markup language, but I thought the 'form' tag had the ability to send a variable to a script and run the script.   2) Is there a way to test an apache configuration? Is it possible for apache to use 127.0.0.1 as the 'ServerName' (i.e. ServerName 127.0.0.1:80 in my httpd.conf file)Basically, I just want to write cgi scripts for some webpages I'm hand-coding and test them on my home laptop. I don't seem to know how to do that and I could use some help.   TIA.
Simple questions about apache and cgi
html;apache;cgi
1) why is apache involved at all? Is it needed to send the variables gathered in the html form to the script? If so, why? I know that html is just a markup language, but I thought the 'form' tag had the ability to send a variable to a script and run the scriptCGI is a form of server-side scripting, a CGI script runs on the web server, not on the web client. There is also client-side scripting. These days that usually takes the form of Javascript embedded in script tags in HTML documents. This is unrelated to CGI.At root, your web browser really only has two jobs: requesting data from other computers via a network protocol called HTTP, and rendering the data it gets back in some pretty fashion on your screen. The only thing your browser knows about your web form is that is that when you press the submit button, it should send a request to some Internet address with the name of the script and the data from the form. The browser doesn't know anything about Python, or where in the file system the document 'test.py' lives. It doesn't even know that 'test.py' is a script. Another piece of software has to be running to receive the browser's requests, look up the data it asks for, and send it back to the browser. That other piece of software is the web server, in this case Apache. Apache has to be configured so that when it gets the request for 'test.py from the browser, it knows where test.py is in the file system, that when it sees a request for a file ending in .py it shouldn't just transmit the contents of the file back to the browser, but rather that is should start a copy of the python interpreter using that script, pass it the form data that came with the request, and then send the output of the script back to the browser. One issue that may be making this more confusing for you: I ove-simplified when I said your browser really only has two jobs. As a convenience, most browsers can also act as local file viewers, that is, you can do an File Open on a local file, and the browser will render that file, without having requested it from a web server. The browser still won't know anything about running scripts unless they're embedded in a script tag as part of an HTML document.