//
// This code will create a Node Express program that uses forms for input. It will create a route for GET requests, which will render an HTML form, and a route for POST requests, which will retrieve the form data from the request body and send back a response. Finally, it will assign a port and start the server.
//
// When you submit the form, you will get an output in the form of a response. The response will include the name and age that you entered in the form.
Test it and get it running
Next Steps:
Hook up your Database connection
Get our PUG Template Going
// To include PUG template, first install the pug module:
// npm install pug
// Then set the view engine of the app to pug:
app.set('view engine', 'pug');
// Then create a view file (e.g. index.pug):
// h1 Hello World!
// Finally, render the view file in the route:
app.get('/', function(req, res) {
res.render('index');
});
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (