HJW

Initial commit.

node_modules
\ No newline at end of file
var http = require('http');
http.createServer(function (req, res) {
var path = req.url.replace(/\/?(?:\?.*)?$/, '').toLowerCase();
switch (path) {
case '':
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Homepage');
break;
case '/about':
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('About');
default:
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Not Found');
break;
}
}).listen(3000);
console.log('Server started on localhost:3000; press Ctrl-C to terminate....');
\ No newline at end of file
var express = require('express');
var fortunes = [
"Conquer your fears or they will conquer you.",
"Rivers need springs.",
"Do not fear what you don't know.",
"You will have a pleasant surprise.",
"Whenever possible, keep it simple.",
];
var app = express();
app.use(express.static(__dirname + '/public'));
var handlebars = require('express-handlebars').create({ defaultLayout: 'main' });
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.set('port', process.env.PORT || 3000);
app.get('/', function (req, res) {
res.render('home');
});
app.get('/about', function (req, res) {
var randomFortune = fortunes[Math.floor(Math.random() * fortunes.length)];
res.render('about', { fortune : randomFortune});
});
//404 Page
app.use(function (req, res, next) {
res.status(404);
res.render('404');
});
app.use(function (err, req, res, next) {
res.status(500);
res.render('500');
});
app.listen(app.get('port'), function () {
console.log('Express started on http://localhost:' + app.get('port')
+ '; press Ctrl-C to terminate.');
});
\ No newline at end of file
{
"name": "meadowlark",
"version": "1.0.0",
"description": "",
"main": "meadowlark.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
<h1>404 - Not Found</h1>
<h1>500 - Server Error</h1>
\ No newline at end of file
<h1>About Meadowlark Travel</h1>
<p>
Your fortune for the day:
</p>
<blockquote>{{fortune}}</blockquote>
\ No newline at end of file
<h1>Welcome to Meadowlark Travel</h1>
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>Meadowlark Travel</title>
</head>
<body>
<header><img src = "/img/logo2.png" alt="Meadowlark Travel Logo"></header>
{{{body}}}
</body>
</html>
\ No newline at end of file