Simple HTTP Server for local testing
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 2030Which 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-filesto Chrome when launching it.
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 edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>