This Python script creates a simple HTTP server using the http.server
module, allowing you to serve static files from your local machine.
-
Place the files you want to serve in the same directory as the script.
-
Run the script using Python 3:
python server.py
-
Open your web browser and navigate to http://localhost:8080/ to view the files.
-
Automatic Index File: If no file is specified in the URL (e.g.,
http://localhost:8080/
), it servesindex.html
by default. -
Error Handling: If the requested file is not found, the server responds with a 404 status code and a "File not found" message.
-
Customizable Port: You can change the port number by modifying the
server_address
variable in the script.