Created
September 1, 2011 15:59
-
-
Save paduc/1186498 to your computer and use it in GitHub Desktop.
How to serve a static html file with Express. Anyone have something better?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.configure(function(){ | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(express.bodyParser()); | |
app.use(express.methodOverride()); | |
app.use(app.router); | |
app.use(express.static(__dirname + '/public')); | |
app.set("view options", {layout: false}); | |
// make a custom html template | |
app.register('.html', { | |
compile: function(str, options){ | |
return function(locals){ | |
return str; | |
}; | |
} | |
}); | |
}); | |
app.get('/', function(req, res){ | |
res.render('index.html'); | |
}); |
But, it's not serving the css/js/images. How can we also serve them without 404s?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes it does work. That was easy!