Prototyping: Simplest HTTP server with URL routing (to use w/ Backbone.Router)?
backbone-routing, backbone.js, httpserver, prototyping, simplehttpserver
Solution
Just use the built in python functionality in `BaseHTTPServer`
import BaseHTTPServer
class Handler( BaseHTTPServer.BaseHTTPRequestHandler ):
def do_GET( self ):
self.send_response(200)
self.send_header( 'Content-type', 'text/html' )
self.end_headers()
self.wfile.write( open('index.html').read() )
httpd = BaseHTTPServer.HTTPServer( ('127.0.0.1', 8000), Handler )
httpd.serve_forever()
Problem
We're working on a Backbone.js application and the fact that we can start a HTTP server by typing `python -m SimpleHTTPServer` is brilliant. We'd like the ability to route any URL (e.g. `localhost:8000/path/to/something`) to our `index.html` so that we can test `Backbone.Router` with HTML5 `pushState`. What is the most painless way to accomplish that? (For the purpose of quick prototyping)