Page 275 -
P. 275
web development
What you need to do next depends on the operating
system you’re running your web server on.
If you are running on Windows, stop reading right now and
proceed to the Test Drive. However, if you are running a Unix-
based system (such as Linux, Mac OS X, or BSD) you need to
do two things to prepare your CGI script for execution:
1. Set the executable bit for your CGI using the chmod +x command.
2. Add the following line of code to the very top of your program:
#! /usr/local/bin/python3
From your terminal window, type
chmod +x generate_list.
py to set the executable bit. You
need do this only once.
Test Drive
To test drive your CGI script, you need to have a web server up and running. The code to
simplehttpd.py is included as part of the webapp.zip download. After you unpack the ZIP
file, open a terminal window in the webapp folder and start your web server:
File Edit Window Help WebServerOnWindows Use this command
c:\Python31\python.exe simplehttpd.py on Windows-based
Starting simple_httpd on port: 8080 systems.
File Edit Window Help WebServerOnUNIX
$ python3 simple_httpd.py
Starting simple_httpd on port: 8080
Use this command
on Unix-based
systems.
you are here 4 239