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:-
Creating the Server
Testing the Server on various devices
Let's Create the Server
Make a directory(folder) and name it whatever you like. I have named it server_dir.
Withing the folder, make a new text file. Open it with notepad.
Paste the following code within that file.
python -m http.server 8000
Now go to File Menu of Notepad and click on Save As. Save it as server.bat
Our server is ready to be tested now.
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.
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.