teller
Simple node.js webserver.
Dependencies: crossroads, ejs, filed, formidable, wrench.
Installation
npm install teller
var app = app
Routing
See crossroads.addRoute for more documentation on route patterns. Teller only supports string patterns, and named variables are available in req.route.
app.get(route, callback)
Add an GET route with callback.
app
app.post(route, callback)
Add a POST route with callback.
app
app.delete(route, callback)
Add a DELETE route with callback.
app
app.settings(settings)
Settings for template rendering and static file serving.
app
app.listen(port)
Begin accepting connections on the specified port.
app
Request
req.route
Contains named variables (see Routing) as key-value pairs.
app
req.query
Contains a parsed query string for GET requests.
app
req.body
Contains a parsed form body for POST & DELETE requests.
app
Response
res.json(obj [, statusCode])
Render the object as json.
app
res.redirect(url [, statusCode])
Redirect to another url.
app
res.render(template [, data [, statusCode]])
Render the specified template. Template directory must be specified in app.settings().
app
res.send(data [, contentType [, statusCode]])
Renders a string, with optional Content-Type header and status code.
app
res.show404()
If settings.template['404']
is supplied, renders a custom 404 page, otherwise sends the default 404 page.
app