PYTHON SimpleHTTPServer

Standard

SimpleHTTPServer is a PYTHON module that provides a simple HTTP server with standard GET and HEAD request handlers
is a quick web server that doesn’t need any other installations or configurations (it much more easier than APACHE)

can use this to turn any directory in your system into your web server directory

type this code on the bash terminal to start a HTTP server on port 8000 (which is the default port)*
# python -m SimpleHTTPServer [port]
this will now show the files and directories which are in the current working directory

to share files and directories, in the terminal, move to the directory folder that you want to be accessible by browsers and HTTP
# cd /var/www/
then, type this command ( -m means “module”)
# python -m SimpleHTTPServer 8000

open the browser to test the connection like this
http://your_ip_address:8000
with the loopback address (or the local IP address shown by ifconfig)
http://127.0.0.1:8000

if there isn’t an index.html file in the directory, all files and directories will be listed
as long as the HTTP server is running, the terminal will update as data are loaded from the python web server

on the terminal are listed all standard HTTP logging information (GET and PUSH), 404 errors, IP addresses, dates, times, and all that you would expect from a standard HTTP log as if you were tailing an APACHE access log file

* this command work on unix system: to run the same command on Windows, on cmd, the syntax is sligther different:
# python -m http.server 8000

 

Advertisements