Answers for "node js starting template"

1

node js starting template

/*
Terminal Commands:
npm init
npm install express
*/

//index.js commands:
const express= require('express');
const app= express();

app.use(express.static(__dirname));     //server css file as static otherwise css won't be seen in index.html when sent through sendFile()

//handling get request for home route
app.get("/",function(req,res){     
  res.sendFile(__dirname+"index.html");
});

//handling post request for home route
app.post("/",function(req,res){
	res.send("Post request Recieved!");
});

//makes the server to reserve port 3000 for this application
app.listen("3000",function(){
	console.log("Server running on port 3000");
});
Posted by: Guest on December-24-2021
0

Node Js templates

$ npm i vue vuex vue-loader css-loader vue-template-compiler node-sass sass-loader postcss-loader postcss-loader webpack-node-externals webpack-merge webpack babel-core babel-loader babel-plugin-transform-object-rest-spread babel-preset-env --save
Posted by: Guest on November-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language