| 
	
		| Installation and Startup
 
 |  
		| 1. Create a directory on your home computer that will be the 
		equivalent of the public_html directory at school.  For 
		the sake of these instructions, I'll refer to it as webdir,  
		but you can 
		call yours anything you want, like "web_project" or even "public_html". |  
		| 2. Download this .zip file:
		pws-24.zip |  
		| 3a. (for Windows): Unzip the contents of that file into the webdir directory.  
		Examine that directory to make sure that it now has another subdirectory 
		called ServerTests.  If it doesn't, 
		then start again. |  
		| 3b. (for Mac and Unix): - copy the downloaded .zip file into the webdir 
		directory
 
 - open a Terminal window and cd  to the
		webdir directory
 
 - Execute the following command to unzip the files:
 unzip pws-24.zip
 
 - make sure that it created the subdirectory called ServerTests. If not, try again to unzip all the .zip files 
		into this webdir directory.
 
 - Execute the following command to set execution permissions for 
		the *.py and *.sh files:
 sh permissions.sh
 
 |  
		| 5. Starting the pws server manually from a terminal or cmd window: Execute the following command:
 python -m stuy_server --cgi --bind 
		127.0.0.1
 |  
		| or |  
		| 5a: Windows: double-click on the webserver.bat 
		file in the webdir directory. |  
		| or |  
		| 5b. Mac & Unix: execute the sh webserver.sh 
		command |  
		| 6. Shutting the pws server down: When the webserver 
		starts up, it will create a new window displaying the work that it's 
		doing.  To shut it down, hit Ctrl-C in the web server's window, or just 
		close that window if repeatedly pressing Ctrl-C doesn't work. 
 Be sure to shut the server down when not in use!
 
 |  |  | 
	| Usage
 
 
 |  | 1. Once pws is running, you can open a 
		browser and use it to go to address: http://localhost:8000
 ...then you should immediately see a webpage telling you that the 
		server is running, and allow you to test it.  If that doesn't work, 
		check the steps 1-5 in the installation instructions to the left.
 
 In particular, for the Mac/Unix, make 
		sure that all Python programs in each of the directories that were 
		downloaded have their execution permissions set.
 |  | Directories:  The 
		webdir directory is equivalent to your public_html 
		directory at school. 
 To show you the equivalencies in addresses, let's suppose your school 
		account is pbrooks and you have a program called fred.py 
		in your public_html directory.  The URL to address that 
		program would be:
 
 http://lisa.stuy.edu/~pbrooks/fred.py
 or
 http://moe.stuy.edu/~pbrooks/fred.py
 
 If you put the fred.py file into your webdir directory 
		at home and bring up the pws webserver, you can access that program (but 
		only on your own computer) with the url:
 
 http://localhost:8000/fred.py
 
 If you'd rather put your project files 
		into a directory of their own (say, "my_project"), create a subdirectory 
		of webdir called my_project and also, at school, 
		create a subdirectory of public_html called my_project, 
		and if you've placed your fred.py file into both of these 
		subdirectories, then you can access the one at home:
 
 http://localhost:8000/my_project/fred.py
 
 and the one at school:
 
 http://lisa.stuy.edu/~pbrooks/my_project/fred.py
 
 
 |  | Using subdirectories of 
		webdir: 
 If you'd rather put your project files 
		into a directory of their own (say, "my_project"), create a 
		subdirectory 
		of webdir called "my_project" (or some other 
		name) and also, at school, 
		create a subdirectory of public_html called "my_project", 
		and if you've placed your fred.py file into both of these 
		subdirectories, then you can access the one at home:
 
 http://localhost:8000/my_project/fred.py
 
 and the one at school:
 
 http://lisa.stuy.edu/~pbrooks/my_project/fred.py
 
 Important Note - Problem and Workaround:
 There's a peculiarity of the PythonWebServer.  When the webserver 
		executes one of your Python programs, that Python program will think 
		that it's connected to the webdir directory, 
		no matter where the Python file is actually located. For instance, if 
		your Python program fred.py is located in the 
		webdir/my_project directory, when fred.py starts 
		executing, it will think it's connected to the webdir 
		directory and not the webdir/my_project 
		directory.
 
 This will be a problem if there are files in the same directory as 
		fred.py, such as harry.csv and when fred.py runs, 
		it will try to open that file with the command:
 
 f = open("harry.csv", "r")'
 
 This will fail because even though 
		fred.py and harry.csv are both in the same directory, 
		fred.py thinks it's in the webdir 
		directory because of the way the webserver executes fred.py.
 
 Workaround:
 You will see a Python file called StuyTools.py in the 
		webdir directory.  Copy StuyTools.py 
		into the same directory as your fred.py file and put the 
		following two lines of code near the top of your fred.py file 
		so that they execute first:
 
 import StuyTools
 StuyTools.PWS_startup()
 
 This will automatically change the directory that fred.py 
		thinks it's connected to, to the same directory that fred.py is 
		in.
 
 |  |