npm install teller#teller
Simple node.js webserver.
Dependencies: crossroads, ejs, filed, formidable, wrench.

``javascript`
npm install teller
`javascript`
var app = require('teller')
app.get('/', function(req, res) {
res.json({ foo: 'bar' })
}).listen(1234)
See crossroads.addRoute for more documentation on route patterns. Teller only supports string patterns, and named variables are available in req.route.
Add an GET route with callback.
`javascript`
app.get('/', function(req, res) {
res.send('Hello world!
')
})
Add a POST route with callback.
`javascript`
app.post('/add', function(req, res) {
res.json(req.body)
})
Add a DELETE route with callback.
`javascript`
app.delete('/image', function(req, res) {
res.json(req.body)
})
Settings for template rendering and static file serving.
`javascript`
app.settings({
template: { dir: __dirname+'/templates', 404: '404.ejs' },
static: { route: '/public', dir: __dirname+'/public' }
})
Begin accepting connections on the specified port.
`javascript`
app.listen(1234)
Contains named variables (see Routing) as key-value pairs.
`javascript`
app.get('/:foo:', function(req, res) {
console.log(req.route.foo)
// GET /bar would log 'bar'
})
Contains a parsed query string for GET requests.
`javascript`
app.get('/qs', function(req, res) {
console.log(req.query.foo)
// GET /qs?foo=bar would log 'bar'
})
Contains a parsed form body for POST & DELETE requests.
`javascript`
app.post('/form', function(req, res) {
console.log(req.body.foo)
// POST /form foo=bar would log 'bar'
})
Render the object as json.
`javascript`
app.get(route, function(req, res) {
res.json({ foo: bar })
})
Redirect to another url.
`javascript`
app.get(route, function(req, res) {
res.redirect('/login')
})
Render the specified template. Template directory must be specified in app.settings().
`javascript`
app
.settings({ dir: __dirname+'/templates' })
.get(route, function(req, res) {
res.render('template.ejs', data, statusCode)
})
Renders a string, with optional Content-Type header and status code.
`javascript`
app.get(route, function(req, res) {
res.send('hello
')
})
If `settings.template['404']` is supplied, renders a custom 404 page, otherwise sends the default 404 page.
`javascript``
app.get(route, function(req, res) {
res.show404(data)
})