Sunday, 18 November 2018

Share files and directories using Python SimpleHTTPServer


SimpleHTTPServer module that comes with Python. It provides standard GET and HEAD functions.

It can be used to set up a very basic web server serving files relative to the current directory. You can use this to turn any directory in your system.

Advantage with the built-in HTTP server is that you don't have to install and configure anything. The only thing that you need, is to have Python installed.

To start a HTTP server on port 8888

manivel@manivel ~/webserver $  python -m SimpleHTTPServer 8888
Serving HTTP on 0.0.0.0 port 8888 ...

       -m     ---> module-name
       8888 ---> port  (You can also change the port to something else)

This will now show the files and directories which are in the current working
directory.

Open your favorite browser and type in any of the following addresses:

http://localhost:8888  or  http://127.0.0.1:8888   or   http://ipaddress:8888



If you don't have an index.html file in the directory, then all files and directories will be listed.



No comments:

Post a Comment