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

Python Web Server with Sockets

The document outlines a simple web server implementation using Python sockets. It includes the aim, algorithm, and a program that sets up a server listening on localhost at port 8000, handling client requests and responding with a basic HTML message. The output and result sections are left blank.

Uploaded by

Balaji Bala
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)
6 views2 pages

Python Web Server with Sockets

The document outlines a simple web server implementation using Python sockets. It includes the aim, algorithm, and a program that sets up a server listening on localhost at port 8000, handling client requests and responding with a basic HTML message. The output and result sections are left blank.

Uploaded by

Balaji Bala
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

EXP NO:09

DATE:
Web Server using Sockets

AIM:

ALGORITHM:

PROGRAM:
import socket
server_socket = [Link](socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('localhost', 8000))
server_socket.listen(1)

print("Web server running on [Link]


while True:
client_connection, client_address = server_socket.accept()
request_data = client_connection.recv(1024).decode()
print("Received request:\n", request_data)
response = """\
HTTP/1.1 200 OK
<html>
<head><title>My Web Server</title></head>
<body><h1>Hello from Python Web Server!</h1></body>
</html>
"""
client_connection.sendall([Link]())
client_connection.close()

OUTPUT:

RESULT:

You might also like