Last active
December 29, 2020 17:14
-
-
Save troygoode/5851859 to your computer and use it in GitHub Desktop.
basic example node.js (+express +jade) application configured to run in Heroku
(views_layout.jade and views_home.jade should just be "layout.jade" and "home.jade" inside the "views" subdirectory)
(public_home.js should just be "home.js" inside the "public" subdirectory)
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": "example", | |
"version": "0.0.1", | |
"private": true, | |
"engines": { | |
"node": "0.10.x", | |
"npm": "1.2.x" | |
}, | |
"dependencies": { | |
"express": "*", | |
"jade": "*" | |
} | |
} |
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
web: node server.js |
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
$(function(){ | |
alert('Hello world.'); | |
}); |
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 app = module.exports = express(); | |
app.set('view engine', 'jade'); | |
app.set('views', __dirname + '/views'); | |
app.use(express.static(__dirname + '/public')); | |
app.use(app.router); | |
app.get('/', function(req, res){ | |
res.render('home', {sayHelloTo: 'world'}); | |
}); | |
if(!module.parent){ | |
app.listen(process.env.PORT || 3000, function(){ | |
console.log('up and running'); | |
}); | |
} |
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
extends layout | |
block title | |
title Overriden Example | |
block scripts | |
script(src="http://code.jquery.com/jquery-1.10.0.min.js") | |
script(src="/home.js") | |
block content | |
p Hello #{sayHelloTo}. |
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
doctype 5 | |
html(lang="en") | |
head | |
block title | |
title Example | |
block stylesheets | |
body | |
block body | |
block scripts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the gist, Troy. However, it looks like there have been some changes since you posted, and with this example, Heroku is throwing errors on page load.
When running from the heroku console, it talks about deprecation of app.router