From 0d13de1791dc40573b55d7ef7124b685a819ef2f Mon Sep 17 00:00:00 2001 From: Ian Millington Date: Mon, 21 Jun 2010 21:01:30 +0100 Subject: [PATCH] Added minimal web-servers for developers who are finding browser issues with running Undum from a file:/// url. --- test_webservers/README.md | 32 ++++++++++++++++++++++++++++++++ test_webservers/serve.py | 13 +++++++++++++ test_webservers/serve.rb | 18 ++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 test_webservers/README.md create mode 100755 test_webservers/serve.py create mode 100755 test_webservers/serve.rb diff --git a/test_webservers/README.md b/test_webservers/README.md new file mode 100644 index 0000000..513df91 --- /dev/null +++ b/test_webservers/README.md @@ -0,0 +1,32 @@ +# Web Servers + +This directory contains minimal web-servers in common scripting languages. +These are designed to expose the `games` directory at http://localhost:8000/ +so that you can debug your creation in the browser more easily. This is +needed because some browsers refuse to store data in localSettings when +serving files from a file:/// url. Simply start one of these servers +and use the http://localhost:8000/ address instead. + +For example, the ruby server (requires Ruby installed): + + ruby serve.rb + +Or on a unix-type machine; + + ./serve.rb + +Similarly for Python (again you'll need Python installed) + + python serve.py + +or + + ./serve.py + +You might already have Python installed, it is installed on Macs and Linux +machines by default. + +If you have a minimal (< 20 lines) web server that can do this job in another +language, please ping me and I'll add it here. I am particularly interested in +servers that will run out of the box on Windows. I will not include .exe files, +however. \ No newline at end of file diff --git a/test_webservers/serve.py b/test_webservers/serve.py new file mode 100755 index 0000000..a8e097b --- /dev/null +++ b/test_webservers/serve.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import SimpleHTTPServer, BaseHTTPServer, os + +os.chdir('../games') +try: + print "Server starting. Visit http://localhost:8000/ in your browser." + BaseHTTPServer.test( + SimpleHTTPServer.SimpleHTTPRequestHandler, + BaseHTTPServer.HTTPServer + ) +except KeyboardInterrupt: + print diff --git a/test_webservers/serve.rb b/test_webservers/serve.rb new file mode 100755 index 0000000..8df332e --- /dev/null +++ b/test_webservers/serve.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require 'webrick' + +include WEBrick + +def start_webrick(config={}) + config.update(:Port => 8000) + puts "Server starting. Visit http://localhost:8000/ in your browser." + server = HTTPServer.new(config) + yield server if block_given? + ['INT', 'TERM'].each { |signal| + trap(signal){ server.shutdown} + } + server.start +end + +start_webrick(:DocumentRoot => '../games') \ No newline at end of file