the server recognizes the web resource as an executable scriptsees that it is python programand executes it with the python interpreterusing the data sent along from the browser form as input the script runsmanipulates its input data into some resultsand puts those results into the text of web page that is the output of the program via print statements the server captures this output from the program and sends it back to your browser as new page to display you see the results in your browser close the server window test what happens if you try to reload the web link you refer to localhostbut you just stopped the local server for the rest of this we will be wanting to use the local serverso restart it in the example www folderin manner appropriate for your operating systemwindowswhatever worked when you started it the first time macstart the local server whatever way worked last timeeither double clicking on cgiserverscript that you should have createdor right/control click on localcgiserver py in the finder windowand select open with -python launcher now you can keep the local server going as long as you want to run cgi scripts from the same folder if you ever want be have cgi scripts and supporting files in different folderstop the server for any other folder firstand start it up in the folder where you have your materials simple buildup before we get too complicatedconsider the source code of couple of even simpler examples hellotxt cgi the simplest case is cgi script with no input that just generates plain textrather than html assuming you have your local server goingyou can go to the link directoryhellotxt cgiand below for you to read#!/usr/bin/env python required header that tells the browser how to render the text print("content-typetext/plain\ \ "here text -not html print simple message to the display window print("helloworld!\ "the top line is what tells the operating system that this is python program it says where to find the right python interpreter to process the rest of the script this exact location is significant on unix derived server (like any mac with os xin windows the only thing important in the line is the distinction between python and if you leave the line there as part of your standard textyou have one less thing to think about when uploading to unix server or running on mac the first print function is telling the server receiving this output that the format of the rest of the output will be plain text this information gets passed back to the browser later this line should be included exactly as stated if you only want the output to be plain text (the simplest casebut not our usual casethe rest of the output (in this case just from one print functionbecomes the body of the plain text document you see on your browser screenverbatim since it is plain text the server captures this output and redirects it to your browser dynamic web pages