This file contains 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
//requiring express and handlebars | |
//.create() method configures handlebars. We’ll explain that in a while | |
const express = require('express'), | |
hbs = require('express-handlebars').create({defaultLayout: 'main', extname: 'hbs'}); | |
app = express(); | |
//set the app engine to handlebars | |
app.engine('hbs', hbs.engine); | |
app.set('view engine','hbs'); |
This file contains 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
const express = require('express'), | |
app = express(); | |
app.get('/',(request,response)=>{ | |
response.send(‘Hello world’); | |
}); | |
//Binding the server to a port(3000) | |
app.listen(3000,()=>console.log(‘express server started at port 300’)); |
This file contains 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
const express = require('express'), | |
body_parser = require('body-parser'), | |
hbs = require('express-handlebars').create({defaultLayout: 'main',extname:'hbs'}); | |
session = require('express-session'), | |
csurf = require('csurf'), | |
app = express(); | |
//setting the app port | |
app.set('port', process.env.PORT || 3000); |
This file contains 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
//server.js | |
const express = require('express'), | |
https = require('https'), | |
http = require('http'), | |
fs = require('fs'), | |
app = express(); | |
//credentials obtained from a Certificate Authority | |
var options = { |
This file contains 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 html> | |
<html> | |
<head> | |
<meta charset='UTF-8'> | |
<title>Form page</title> | |
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js'></script> | |
<style> | |
*{ | |
margin:0; | |
padding:0; |
This file contains 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
//server.js | |
const express = require('express'), | |
app = express(), | |
//You must require the body-parser middleware to access request.body in express | |
bodyParser = require('body-parser'); | |
//configuring bodyparser | |
app.use(bodyParser.json()); |
This file contains 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
//server.js file | |
const express = require('express'), | |
app = express(); | |
//setting the port | |
app.set('port', process.env.PORT || 3000); | |
// | |
app.get('/',(request,response)=>{ |
This file contains 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
const express = require('express'), | |
app = express(); | |
//setting the port | |
app.set(‘port’, process.env.PORT || 3000); | |
//first middleware | |
app.use((request,respone,next)=>{ | |
console.log(`processing for data for ${request.url}`); | |
next(); |
This file contains 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
const express = require('express'), | |
hbs = require('express-handlebars').create({defaultLayout:'main.hbs'}), | |
app = express(); | |
//setting our app engine to handlebars | |
app.engine('hbs', hbs.engine); | |
app.set('view engine', 'hbs'); | |
app.get('/',(request,response)=>{ | |
response.render('home',{title: 'Home'}); | |
}); |