Answers for "how to set up express"

6

how to make an express server

// this is your code
// ZDev1#4511 on discord if you want more help!
// first you should install express in the terminal
// `npm i express`.
const express = require('express');
const app = express();

// route
app.get('/', (req,res)=>{
  // Sending This is the home page! in the page
  res.send('This is the home page!');
});

// Listening to the port
let PORT = 3000;
app.listen(PORT)

// FINISH!
Posted by: Guest on July-03-2020
0

how to set up an express api nodejs

const express = require('express')

const app = express() 

app.get('/', (req, res, next) => {
	res.json({
      message: 'This is my JSON api'
    });
});

app.listen(your-port-here, () => {
	console.log(`listening on http://localhost:${the-port-goes-here}`)
});

/*
WombleWoo7547 @ https://github.com/WombleWoo7547 https://replit.com/@WombleWoo7547
*/
Posted by: Guest on May-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language