python built-in web server - The Coducer

Launch a Simple HTTP Web Server with Python in less than a minute

Overview

In this post we will learn how to launch the built-in-web server in Python.

What is a SimpleHTTPServer?

The SimpleHTTPServer module is an in-built web server in Python that provides standard GET and HEAD request handlers. The SimpleHTTPServer module has been merged into http.server in Python 3.

Pre-requisites:

  • A Computer
  • Python installed (If not, click here)
  • Working Internet Connection

How to start?

  1. Open Command Prompt on Windows.
  2. Press Win-Key + R and type cmd and skip step 1.
  3. In your terminal, cd into whichever directory you wish to have accessible via browsers and HTTP.
  4. Now, type python -m http.server [port] (can use the default port: 8000) and enter. Voila! Your built-in Python web server is running.
  5. Open your favorite browser and type http://localhost:8000 or http://127.0.0.1:8000
  6. If you don’t have an index.html file in the directory, then all files and directories will be listed.
  7. Check your terminal. You should see standard http logging informations. It will update as long as http server is running.

Simple and Easy-to-Launch

You don’t have to install or configure anything. The only thing you need is Python installed. This makes launching a simple web server in less than a minute. While there are many web server softwares out there (apache, nginx) but running built-in Python web server is really easy.


If this post was helpful, share this on your social circles. Comment down below if you face any issues.

Advertisements

Published by

The Coducer

A geek, a curious learner, pro-procrastinator, wanderer. Love to meet new people and make new friends. Happy to have you here! Follow @thecoducer on Twitter, Instagram.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s