Commit 82c89449 authored by Sorrel Harriet's avatar Sorrel Harriet
Browse files

adding files ofr lab 5

parent 8a0ffacb
# Lab 5 Resources
To run either of the simple server scripts, first make the files executable:
chmod +x simpleServer.py
chmod +x index.html
chmod +x cgi-bin/splash.py
Then you can launch the server by executing:
./simpleServer.py
To test it from a browser you first need to know your server's ID and/or WWW port number. You can get that information from the [Virtual Server Manager](https://www.doc.gold.ac.uk/dept/VirtualServer).
From inside the college network it will be in the form: http://myserver.doc.gold.ac.uk:58106/
Or outside: http://www.doc.gold.ac.uk/usr/106/
Replace the \`106' in the above URL's with the ID of your own virtual server!
File mode changed from 100644 to 100755
......@@ -11,10 +11,9 @@
"""
import http.server
import socketserver
import cgitb; cgitb.enable()
PORT = 8888 # specifies the port number to accept connections on
PORT = 8000 # specifies the port number to accept connections on
server = http.server.HTTPServer # provides simple web server
handler = http.server.CGIHTTPRequestHandler # provides request handler
......
#!/usr/bin/env python3
# above 'she-bang' line makes the script executable from command line
""" A Very Simple Web Server
Run with ./verySimpleServer.py
Make sure all cgi scripts are executable
for single script:
chmod +x script.py
or for a whole directory:
chmod -r +x htdocs/
"""
import http.server
import socketserver
PORT = 8000 # specifies the port number to accept connections on
handler = http.server.SimpleHTTPRequestHandler # provides request handler
server_address = ("", PORT) # specify server directory and port number
print("Starting server...") # outputs a message
httpd = socketserver.TCPServer(server_address, handler) # creates the server, passing it the server address and port number, as well as the CGI handler (httpd stands for HTTP Daemon)
print("serving at port", PORT) # outputs a message
httpd.serve_forever() # puts program in infinite loop so that the server can `serve_forever'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment