Create your own local Web Server with python on Windows in one line

We are going to make our own testing web server with python in one line in two simple steps:-

1

Creating the Server

2

Testing the Server on various devices

01

Let's Create the Server

Make a directory(folder) and name it whatever you like. I have named it server_dir.

local-python-server-directory

Withing the folder, make a new text file. Open it with notepad.

local-python-server

Paste the following code within that file.

python -m http.server 8000

local-python-server

Now go to File Menu of Notepad and click on Save As. Save it as server.bat

local-python-server

Our server is ready to be tested now.

02

Let's Test the Server

Let's create a simple Website to serve on our server. Create a HTML file named index.html and paste the following within that file.

See the Pen abpKQmv by stackinverse (@stackinverse)on CodePen.

You can even create your own complete website but the index.html page of the Website must be in the root directory where server.bat file is present.

After creating the index.html file, click-open the server.bat file. Your server is now ready to accept requests.

Open any Web Browser and paste localhost:8000 into the URL(or search) bar. Your Website will show up! Feel free to experiment with the code to understand it properly.