0% found this document useful (0 votes)
8 views2 pages

Simple HTTP Server

The document provides an overview of HTTP, detailing how to retrieve and send data using GET and POST methods. It includes sample Python code for creating a simple HTTP server using the http.server and socketserver modules. Additionally, it instructs the reader to implement a do_put method to save registration details to a text file.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Simple HTTP Server

The document provides an overview of HTTP, detailing how to retrieve and send data using GET and POST methods. It includes sample Python code for creating a simple HTTP server using the http.server and socketserver modules. Additionally, it instructs the reader to implement a do_put method to save registration details to a text file.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like