tags:

views:

1426

answers:

13

Hi,

I'm playing with Windmill (similar to selenium) with is fun but one of the requirements is that is must be run over http. The project I'm working on is a fat client web app, all of our unit tests are just run on the local file system as there is no need for HTTP as all of the data services are mocked.

So basically what I'm looking for is a very light weight http server which will only be used for serving static files. I want to be able to write a simple bash script, that starts the web server, then runs the selenium test, then shuts down the webserver.

Something that is a single file would also be nice. I see there are a lot of options but I'm spoiled for choice, so was looking for recommendations.

Regards,

Chris

Edit: Ideally this should be a cross platform solution

Edit: Sorry to extend further, I would love a single file which I could drop in any folder then just call $someApp start and it starts serving those files on one of the localhost ports

+1  A: 

web.py is a pretty good choice.

bchhun
+1  A: 

NGinx (or LigHTTPD)

alphadogg
+5  A: 

On Unix:

Nginx - http://nginx.net/

Lighttpd - http://www.lighttpd.net/

Andy Hume
Great minds think alike! :)
alphadogg
Lighttpd is amazing.
Evan Fosmark
+2  A: 

Jetty is lightweight, and should fit your need pretty nicely.

Don Branson
+5  A: 

I've become a recent fan of cherrypy. It's not single-file, but it's extremely simple to get a small web app running, and it's a very small modification to serve static files.

Here's the complete code to run a simple server on http://localhost:8080 :

import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())
Triptych
"it's a single modification to serve static files" ? I believe you will have to write a couple lines of code to serve files...
f3lix
A: 

thttpd

orlandu63
A: 

litespeedtech.com had a very easy to use and setup webserver for BSD's, Linux and OS X.

It is very fast and very easy to setup.

gbrandt
A: 

httpi: "the little 100% Perl webserver that does tiny things"

nicerobot
+3  A: 

If you only need something simple with low traffic, and Python is your language of choice, why not use the built-in web-server of the Python standard library - BaseHTTPServer. Zero set-up time, nothing new to download, and fully customizable from Python.

See here for one example.

Eli Bendersky
+1 - It sounds like this is exactly what he needs - drop it in a directory, run it, and it's serving files from that directory.
Marc Novakowski
+18  A: 

There is no simpler way than ...

With python 2.4 and later you can use the SimpleHTTPServer module like this

python -m SimpleHTTPServer

This will start a HTTP server on port 8000 serving the files and directories which are in the current working dir.

Advantages:

  • comes with python (>= 2.4), no need to install anything
  • no configuration needed


See Recipe 365606: How to serve files from a directory (and/or testing CGI scripts) and 18.20 SimpleHTTPServer -- Simple HTTP request handler for more information

f3lix
Brilliant. Just saved me hours, I'm sure.To add a bit: use "python -m SimpleHTTPServer 12345" for a different port number.
Matt Miller
A: 

Windmill has it's own Python Fileserver inside of the WSGI proxy server.

The windmill unittests use this server to push out a static directory and serve them.

http://trac.getwindmill.com/browser/trunk/test/test_live/init.py

Once you mount a "namespace" you can access the files at any domain and the proxy will serve them like they aren't local.

-Mikeal

+3  A: 

HFS is a single executable web server. Windows only, but will run under wine. Meant as an end-user web server for file sharing, but it easy to deploy and configure. So it might work. Not really a programmable solution.

Karl Fast
A: 

A nice and efficient webserver is webfsd. From that webpage:

This is a simple http server for mostly static content. You can use it to serve the content of a ftp server via http for example. It is also nice to export some files the quick way by starting a http server in a few seconds, without editing some config file first.
It uses sendfile() and knows how to use sendfile on linux and FreeBSD.
It is a single-process server, based on select() and non-blocking I/O. It supports keep-alive, byte ranges, virtual hosts and IPv6. It generates automatically listings for directories. It has no config file, just a few command line switches.

Emil