/**
 * Tile server using the node web framework Express (http://expressjs.com).
 */
var express = require('express'),
    Tile = require(__dirname + '/../lib/tilelive').Tile,
    app = express.createServer();

app.get('/:scheme/:mapfile_64/:z/:x/:y.*', function(req, res) {
    /*
     * scheme: (xyz|tms|tile (tms))
     *
     * format:
     * - Tile: (png|jpg)
     * - Data Tile: (geojson)
     * - Grid Tile: (*.grid.json)
     */
    try {
        var tile = new Tile({
            scheme: req.params.scheme,
            mapfile: req.params.mapfile_64,
            xyz: [
                req.params.x,
                req.params.z,
                req.params.y],
            format: req.params[0],
            mapfile_dir: '/tmp/mapfiles'
        });
    } catch (err) {
        res.send('Tile invalid: ' + err.message + '\n');
    }

    tile.render(function(err, data) {
        if (!err) {
            res.send.apply(res, data);
        } else {
            res.send('Tile rendering error: ' + err + '\n');
        }
    });
});

console.log('Listening on port: ' + 8888);
app.listen(8888);


@@ -1,10 +1,6 @@
 /
-**%0A *
+/
  Til
@@ -73,23 +73,15 @@
 m).%0A
- */%0Avar express
+var app
  = r
@@ -101,386 +101,197 @@
 ss')
-,%0A    Tile = require(__dirname + '/../lib/tilelive').Tile,%0A    app = express.createServer();%0A%0Aapp.get('/:scheme/:mapfile_64/:z/:x/:y.*', function(req, res) %7B%0A    /*%0A     * scheme: (xyz%7Ctms%7Ctile (tms))%0A     *%0A     * format:%0A     * - Tile: (png%7Cjpg)%0A     * - Data Tile: (geojson)%0A     * - Grid Tile: (*.grid.json)%0A     */%0A    try %7B%0A        var tile = new Tile(%7B%0A            scheme
+.createServer(),%0A    mapnik = require('tilelive-mapnik'),%0A    tilelive = new (require('tilelive').Server)(mapnik);%0A%0Aapp.get('/:z/:x/:y.*', function(req, res) %7B%0A    var options = %7B%0A        x
 : re
@@ -301,16 +301,13 @@
 aram
-s.scheme
+('x')
 ,%0A  
@@ -316,56 +316,35 @@
     
-    mapfile: req.params.mapfile_64,%0A    
+y: req.param('y'),%0A
         
 xyz:
@@ -343,294 +343,143 @@
     
-xy
 z: 
-%5B%0A                req.params.x,%0A                req.params.z,%0A                req.params.y%5D,%0A            format: req.params%5B0%5D,%0A            mapfile_dir: '/tmp/mapfiles'%0A   
+req.param('z'),%0A        format: req.params%5B0%5D,%0A        datasource: __dirname + '/stylesheet.xml'%0A
     
- %7D)
+%7D
 ;%0A    
-%7D catch (err) %7B%0A        res.send('Tile invalid: ' + err.message + '%5Cn');%0A    %7D%0A%0A    tile.render(
+tilelive.serve(options, 
 func

Update example.