Question: Create a Python file named web _ server.py that implements a basic web server with the following functionality: Required Features: 1 . TCP socket creation

Create a Python file named web_server.py that implements a basic web server with the
following functionality:
Required Features:
1. TCP socket creation and configuration
2. HTTP GET request handling
3. File system operations
4. HTTP response generation
5. Basic error handling (404 Not Found)
Your server must:
Listen on port 6789(configurable)
Handle HTTP GET requests
Serve files from the local directory
Send appropriate HTTP headers
Handle file-not-found errors with 404 responses
Use this skeleton code as your starting point:
Web Server Skeleton Code
from socket import *
import sys
class HTTPServer:
def __init__(self, host='localhost', port=6789):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!