python: simple http server for file sharing

May 15th, 2009 mysurface Posted in python | Hits: 212858 | 9 Comments »

You do not need to setup apache server just to hosting your file for sharing. If you have python 2.5 and above, you can do this at the targeted directory to share.

python -m SimpleHTTPServer 9914

9914 is the port number I choose to host my web, assume my IP is 192.168.1.1, in firefox you can ask your friend to access this url: http://192.168.1.1:9914.

It is easy isn’t it? You do NOT even need to run it as root, just run it as normal user but make sure your firewall allow the chosen port number.

9 Responses to “python: simple http server for file sharing”

  1. If that don’t work take a look at a slightly different way to do the same thing.

  2. So how to stop this http service once the supposed file download is completed?

  3. I usually kill it by pressing control+c.

  4. I like how you don\’t need to write a single line of code and that you can use the default behaviour of the HTTP module to host files.

  5. Good instructions.. If you have more than one computer hooked up to a router, you would need to forward 9914 to the specific network IP of the computer that has the file you want to share. Still very easy stuff though..

    Thanks

  6. In Python 3.x it is:

    python -m http.server 9914

  7. Everyone loves what you guys are up too. Such clever work and coverage!

    Keep up the wonderful works guys I’ve incorporated you guys to my own blogroll.

    Also visit my web page … hantu pocong

  8. liquid smoke recipes python: simple http server for file sharing » Linux by Examples

  9. Tremendous things here. I’m very glad to see your post.
    Thanks a lot and I’m having a look forward to contact you.
    Will you please drop me a e-mail?

Leave a Reply