python, server

A simple python server

I guess it’s not a simple python server. It is really simple and easy to deploy python server. Just imagine you want to share a folder on your pc with someone on your network. What you will do ? Obviously you will start the sharing service but what if you have python installed and want an easier solution ? Here you go. You can just type in :

$ python -m SimpleHTTPServer

This should be typed in the terminal or command prompt if you are a windows guy. Just open command prompt. Navigate to the directory which you want to share and then run this command. Unlike the normal sharing services this server will also show you the IP addresses of the PCs which are accessing that folder. Pretty slick right ?

Do share your views about this post below in the comments.


6 thoughts on “A simple python server

  1. >>> normally indicates the Python prompt ($ is often used a shell prompt). To use this webserver in Python, you’ll need to create a SocketServer first and then plug in the SimpleHTTPRequestHandler in there.

    • Philipp it’s not like that. Only this command (-m SimpleHTTPServer ) does the trick. That’s why it is called a Simple server. I have tested it and there’s no need for further setup.

  2. No, you don’t need to run a new Python process to embed the simple HTTP server in your Python application (say, because you want to share your application’s source code or so). SocketServer.TCPServer((“”, 8080), SimpleHTTPServer.SimpleHTTPRequestHandler).serve_forever() (in a new thread) is sufficient

    • Let me clear your confusion. This tutorial is about folder sharing and if i do -m SimpleHTTPServer then i will get the logs as well. I know we can get logs from your method as well but i think we should prefer a one liner than a two or four liner🙂

Leave a Reply

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

You are commenting using your 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