Temporary webserver tip

Soldato
Joined
16 May 2005
Posts
6,509
Location
Cold waters
Here's a way to quickly set up a temporary webserver to share the contents of the current working directory with others as a directory listing webpage.

Code:
#!/bin/bash
LOGFILE="webserver_log_$(date +%s).txt"
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()" &> $LOGFILE

  1. [Setup] Save the code snippet as webserver.sh
  2. [Setup] Make it executable. chmod +x webserver.sh
  3. [Setup] Put it somewhere in your PATH so that you can use it from any directory.

  1. Run it: webserver.sh
  2. Stop it: press Ctrl-C.

  • People on your LAN can view it at http://yourhostname:8000
  • People across the internet can view it if you set your router to forward the external port 80 to youriporhostname:8000
  • You could use DynDns to get a permanent URL for yourself so that you don't have to give people your current IP address (e.g. http://bob.dyndns.org/)
 
Last edited:
Back
Top Bottom