Mac OSX and Linux – Quick and Dirty Web Server

KB ID 0001157 

Problem

I was clearing out some old emails yesterday, and saw one my colleague Steve had sent me. It was info on how to fire up a quick web server on your mac. It wasn’t until I took a look at it, I realised how handy it was.

After some reading, I found that it was not only possible on a mac, but on other flavours of Linux as well, (as long as they support ‘python’ and have it loaded).

WHAT USE IS THAT? What if you want to send a large file to a colleague? Yes you could use USB drives or dropbox, but executing one command is a lot quicker. Or what if you are on a site where everything is locked down, and only a few ports are open but you need to get a file somewhere, do a quick nmap scan and you can download your files over a different port.

Solution

First open a terminal window, then navigate to the folder you want to ‘serve’. Then simply execute the following command;

python -m SimpleHTTPServer 8080

Note: Where TCP port 8080 is the port you want to use.
mac quick web serverThen simply browse to https://{Your-IP-Address}:8080

linux python web server

BE AWARE: You shouldn’t see a problem if you use any port ABOVE 1024, however if you chose a lower port, you may see ‘Permission Denied’ errors.

Python Permission Denied

To address that ‘sudo’ the command, (unless you are logged into Linux as root!)

simpleHTTPServer

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

1 Comment

Submit a Comment

Your email address will not be published. Required fields are marked *