Last active
August 29, 2015 14:05
-
-
Save pinalbhatt/ada0c3df7de1fdf6c46b to your computer and use it in GitHub Desktop.
NodeJS-Simple-Website
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
{ | |
"name": "WebApp", | |
"version": "0.0.0", | |
"description": "WebApp NodeJS Simple WebSite", | |
"main": "server.js", | |
"author": { | |
"name": "Pinal Bhatt", | |
"email": "[email protected]" | |
}, | |
"dependencies": { | |
"express": "^4.7.4", | |
"jade": "^1.5.0", | |
"morgan": "^1.2.2", | |
"nib": "^1.0.3", | |
"stylus": "^0.47.3" | |
} | |
} |
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
var express = require('express'); | |
var stylus = require('stylus'); | |
var nib = require('nib'); | |
var logger = require('morgan'); | |
var app = express(); | |
function compile(str, path) { | |
return stylus(str).set('filename', path).use(nib()); | |
} | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(logger('dev')); | |
app.use(stylus.middleware({ src: __dirname + '/public', compile: compile })); | |
app.use(express.static(__dirname + '/public')); | |
app.get('/', function (req, res) { | |
res.render('index', {title:'Hello, World! from NodeJS'}); | |
}); | |
var port = process.env.port || 1337; | |
app.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment