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'), | |
router = express.Router(); | |
router.get('/',(request,response)=>{ | |
response.send('Home of user'); | |
}); | |
//some other endpoints to submit data | |
module.exports = router; |
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.use('/users',require('./basic_router')); | |
app.use('/api',require('./api_route')); | |
app.get('/posts/newpost',(request,response)=>{ | |
response.send('new post'); | |
}); |
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(); | |
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'), | |
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'}); | |
}); |
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
//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
//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
<!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'), | |
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
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); |