スケルトンファイルの生成
$ node node_modules\express\bin\express newb
$ cd newb && npm install // 依存するモジュールの生成
$ node app.js // Webアプリケーションの実行
# Webサーバの起動
http://localhost:3000
expressのアーキテクチャ
# Routes
app.get('/', routes.index);
# routes/index.js
exports.index = function(req, res) {
res.remder('index', { title: 'Express' )
# テンプレート views/layout.jade
!!!
html
head
title= title
link(rel='stylesheet', href='/dtylesheets/style.css')
body!=body
# views/index.jade
h1= title
p Welcome to #{title}
サンプルアプリケーション「newbmap」
概要
Windows Azure上のBing Mapを用いたアプリケーションで、「JavaScriptでWebアプリを開発するNode.js活用入門」から引用しているので、詳細は、当該記事を参照のこと。
ソースコード
ソースコードは、松下(hylom)さんのPersonalForgeリポジトリからダウンロード可能。