/express-1b
/express-1b/controllers
>npm init
>npm install http-status-codes express
const codes = require('http-status-codes'), br = '<br>'; const homeFct = (req, res) => { res.type('html') res.status(codes.OK); res.write('Greetings from web app' + br); res.write('Hello from controller'); res.end(); }; exports.homeFct = homeFct;
"use strict"; const port = 3000, express = require("express"), hc = require('./controllers/home-controller'), app = express(), msg = `Server started on port: ${port}`; const started = () => console.log(msg); //route path "/" to controller's "homeFct" app.get("/", hc.homeFct); //start the web server app app.listen(port, started);
>node main