Mike Chambers

code = joy

Simple HTTP Server for local testing

with one comment

I am currently playing around with the HTML5 FileSystem API, and have a need to test my files served via a web server. I could setup a virtual director for my local apache server, but given the number of simple tests and experiments I do, I wanted something easier that required little to no configuration and setup.

So, I put together a super simple script that uses python’s SimpleHTTPServer class.

Here is the script (requires that python is installed and in your path)

#!/bin/bash
 
python -m SimpleHTTPServer $1

To use it, just switch the the directory that contains your files and run:

http

This will open a simple webserver on port 8000.

You can optionally pass in the port like so:

http 2030

Which will start a simple web server listening on port 2030.

Again, this is something really simple, but also very useful. If you need to quickly test a file, just switch to the directory and run the script.

Btw, another work around for playing with the FileSystem APIs would be to pass the:

--allow-file-access-from-files

to Chrome when launching it.

Written by mikechambers

April 8th, 2012 at 4:37 pm

Posted in General

Tagged with , , ,

One Response to 'Simple HTTP Server for local testing'

Subscribe to comments with RSS or TrackBack to 'Simple HTTP Server for local testing'.

  1. I just opened OS X preferences and ticked ‘Web Sharing’. You can now test locally through http.

    Fred Williamson

    14 May 12 at 7:37 am

Leave a Reply

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: