PSG COLLEGE OF TECHNOLOGY, COIMBATORE - 641004
Department of Applied Mathematics and Computational Sciences
COMPUTER NETWORKS LAB
HTTP Server
HTTP is the protocol that browsers use to retrieve and push information to
servers. Here's how you could retrieve the about page of a website:
GET /[Link] HTTP/1.0
User-Agent: Mozilla/5.0
And here's how you could send some form data to a web server, using the
POST method:
POST /[Link] HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 21
name=John&surname=Doe
Sample Code
import [Link]
import socketserver
class MyHttpRequestHandler([Link]):
def do_GET(self):
if [Link] == '/':
[Link] = '[Link]'
return [Link].do_GET(self)
# Create an object of the above class
handler_object = MyHttpRequestHandler
PORT = 8000
my_server = [Link](("[Link]", PORT), handler_object)
# Star the server
my_server.serve_forever()
Implement your own HTTP server, so that you can host a dynamic website on it. Implement the
do_put(self) to save the details of a registration page in a txt file.