var express = require('express');
var router = express.Router();
var ctrlHome = require('../controllers/home');
var ctrlContact = require('../controllers/contact');
/* Setup routes to pages */
router.get('/', ctrlHome.home);
router.get('/contact', ctrlContact.contact);
module.exports = router;
Note: As addtional views and controllers are added to your website it is this file alone that is updated accordingly.
contact.js - What follows is the Controller for Contact page:
/* GET contact page. */
module.exports.contact = function(req, res) {
res.render('contact', { title: 'Contact Us' });
};
Note: A single controller .js file may include multiple controllers, each with its own module.exports.<controller_name>
code.var app = express();
for reference:
var routes = require('./routes/index');
var app = express();
...
app.use('/', routes);
/* GET contact page. */
module.exports.contact = function(req, res) {
res.render('contact', { title: 'Contact Us' });
};
Note - Multiple name:value pairs may be sent, separated by commas.
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<p>To contact us please send email to: goaway@nospam.net.</p>
</body>
</html>
> git init
> git add .
> git commit -m "First commit"
Note: After the above is executed you have a local repository known to GIT. However, it still hasn't been published to the remote master repository.
> git remote add origin https://<userid>:<token>@github.com/<userid>/<repo>.git
Where:
> git push -u origin master
If this is the first time you have published to the master repo, then feel free to go to GitHub.com and login
to make sure all the expected files were uploaded and added to your repo. The files in your repo can be easily
shared with others if the repo is public, and easily used by you to redeploy your code in the future.