Database Reference
In-Depth Information
var express = require('express')
, path = require('path')
, app = express()
;
app
.set("port",argv.port)
.set("views",path.join(__dirname,"views"))
.set("view engine","jade")
.use(express.favicon())
.use(express.logger('dev'))
.use(express.json())
.use(express.urlencoded())
.use(express.methodOverride())
.use(app.router) //MVC routing
.use(require('less-middleware')({
src: path.join(__dirname, 'public')
}))
.use(express.static(path.join(__dirname, 'public')));
app
.listen(argv.port);
Like the earlier connect example, the application is first initialized and
then the base middleware attached. The express middleware mostly
supersedes the connect middleware, but third-party connect middleware
can still be used with express . In this case, the default middleware handles
parsingofthevariouspartsoftheURLaswellasthebody.Italsoestablishes
static file delivery from the public directory and rendering of cascading
style sheets (CSS) using the less package. This package is used by Twitter's
Bootstrap, among others, to simplify styling the application. The “jade” view
engine provides a template language used to create dynamic web pages
within the application. It is used in the next section to describe the layout of
the dashboard so that data can be streamed to it.
A Basic Streaming Dashboard
Using the express framework, this section builds a framework for a
streaming dashboard. This is probably the first and most common
application of streaming data. This section provides the framework and
Search WWH ::




Custom Search