Introduction

Although it is easy to start-up IIS under Window O/S or Apache under Unix O/S, we still have another choice to start a web server service using Python programming tools. You only need to install python, and then start python and run the following script line by line:

import http.server, os
#define the server document directory with unix path;
os.chdir(“UsersadministratorDocuments”)
#if it is window env with directory as c:UsersadministratorDocuments
os.chdir(“/Users/goldmanau/Documents”)
httpd = http.server.HTTPServer((‘127.0.0.1’, 8000),
http.server.SimpleHTTPRequestHandler)
httpd.serve_forever()

This script can work under either python 2.7 or 3.x version under window or Unix environment. If you put the index.html to the server document path, then, you can start a web browser and input the link as http://127.0.0.1:8000/index.html in order to display your web page. It is the most easy, simple, fast way to start a web server service.

One thought on “Most Easy Way to Start a Web Server Service Using Python

Leave a Reply

Your email address will not be published.

Enter Captcha Here : *

Reload Image