Create A Website On Your Mac Without A Webserver

Do you need a Website set up right meow?  Using netcat (nc), you can use your Mac to instantly set up a Webpage without configuring a Web server.  This could be used to quickly share files via a Web browser (by creating a hyperlink with file:///some/filepath/), or it could be used as a temporary Website while maintenance is being performed.

This command will create a Webpage that can be downloaded once.  After it is downloaded the program ends and the page will no longer be accessible.  You would need to enter the command again in order to view the page.

nc -l 80  < index.html

That isn’t all that useful, but you can wrap that same command in an infinite loop to keep the page live.  You could use this if your site crashed suddenly and you need to let clients know that you are working on it.

while true;do sudo nc -l 80 < index.html;done

This will create an infinite loop that endlessly responds to requests.  Press Ctrl+Z to end the loop and take down the page.

Now go set up your pseudo-Website right meow.