tags:

views:

306

answers:

3

Hi,

I asked a previous question here but after reading the answers realised I hadn't done a very good job of defining my requirements.

Here's what I'm after:

  • Cross platform
  • Drag, drop and start
  • Preferably a single file

So to sum up I want something that I can just drag into a folder, start up and then it will start servering over http the contents of that folder.

Hope someone knows of something.

Cheers,

Chris

+1  A: 

I have found a some-what small web server in the form of a Firefox addon. It works on any platform that Firefox works on. It can be installed very quickly and can be ready to use in around 45 seconds (I timed myself from the time I started downloading to the time I served my first page). The server sets up a directory for you to use right after it is installed so you could just drag it there and start viewing the page instantly. It also has limited server-side scripting capabilities(SJS) included but can be extended with common languages such as php and Perl. I don't think this would be the server you would use to host Google but it seems to be what you're looking for.

The download is here

+1  A: 

Python implementation:

#!/usr/bin/env python

import SimpleHTTPServer, BaseHTTPServer

def launchServer(ports):
    for port in ports:
     try:
      serv = BaseHTTPServer.HTTPServer(('', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
     except:
      continue
     else:
      print ("Launched on port " + str(port))
      serv.serve_forever()

     raise Exception("No ports available")

launchServer([80] + range(8000, 9000))

For a Windows executable, run this:

python setup.py py2exe

setup.py:

from distutils.core import setup
import py2exe
setup(console=['minipywebd.py'])

On Linux, chmod a+x the python file.

phihag
Exactly what I was looking for. Thanks
ChrisInCambo
A: 

Well it is quite late to answer this one: but python afaik is not single file ;-)

TCL is!

Look at www.equi4.com for a tclkit or starkit. TCL can implement an HTTP server easily. But with a TCL starkit you can even pack the content to be served into the very same file as the webserver and the TCL interpreter and possibly extension.

Building a complete solution is no rocket science but you will have to read yourself into the thing a bit. TCL can be learned in two to three hours if you ever programmed anything before.