Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

setup app files in node js

const express = require ('express')
const path = require('path')
const app = express()

///npm install body-paraser

const bodypraser = require('body-parser'); 
app.use(bodypraser.json())
app.use(bodypraser.urlencoded({extended:true}))


//setup static and middleware
app.use(express.static('./public'))

app.get('/', (req, res) =>{
    console.log('user hit the resource')
    res.sendFile(path.resolve(__dirname, '../../02-express-tutorial/navbar-app/index.html'))
})

app.get('/contact', (req, res) => {
    console.log('user is on contact page')

    res.send('Contact Page')
})
app.get('*', (req, res) =>{
    res.status(404).send("<h1> Resource not found </h1>")
})


app.listen(5000, () => {
    console.log('server is listing on port 5000....');
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: PAN SNAP 
Javascript :: in node.js with express how to remove the query string 
Javascript :: flatten a nested json 
Javascript :: node-mongodb-native keep collection 
Javascript :: Connect session middleware - regenerate vs reload 
Javascript :: remember me option in firebase + react 
Javascript :: select the value of dropdownMenu with Semantic ui react 
Javascript :: Triggering An Event Programmatically With JavaScript 
Javascript :: react text editor snippet 
Javascript :: Declare JSON Variable In Another File 
Javascript :: Import Variable From Module In JavaScript 
Javascript :: ENOENT electron 
Javascript :: phaser rotate matrix 180 
Javascript :: jquery show loader 
Javascript :: Sorting the Odd way! 
Javascript :: A Node Module For ReactJS 
Javascript :: Fibonacci numbers for n terms 
Javascript :: Download A File With Link Using ExpressJS 
Javascript :: let result = 7 + 13 / 9 + 7; let result2 = 100 / 2 * 6; answer= result* result2; result = answer; final Result = result.toFixed(2); final Number = Number(final Result); console.log(finalNumber); 
Javascript :: python code to javascript converter 
Javascript :: prisma usersWithZeroPosts 
Javascript :: onclick readmore and readless react js 
Javascript :: How to Loop Through an Array with a for Loop in JavaScript 
Javascript :: Update react final form field 
Javascript :: How many options are there to climb a ladder with N 
Javascript :: Backbone Collection Example 
Javascript :: how to print reverse number in javascript 
Javascript :: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 
Javascript :: javasript array 
Javascript :: fill array with array javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =