Skip to content

Instantly share code, notes, and snippets.

View vickonrails's full-sized avatar
🖥️
writing code

Victor Ofoegbu vickonrails

🖥️
writing code
View GitHub Profile
<!-- home.hbs -->
<p> Hello I’m just a home file </p>
//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');
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’));
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);
//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 = {
<!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;
//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());
//server.js file
const express = require('express'),
app = express();
//setting the port
app.set('port', process.env.PORT || 3000);
//
app.get('/',(request,response)=>{
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();
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'});
});