Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set up node js server express

npm init -y
npm i express
______

const express = require('express')
const app = express()
const port = 5000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})
Comment

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!
Comment

javascript express server

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})
Comment

express js server

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('<h1>Some HTML</h1>');
  res.send('<p>Even more HTML</p>');
});

app.listen(PORT, () => console.log(`Server is listening on port ${PORT}`));
Comment

starting express server

const express = require("express");
const cors = require("cors");
require("dotenv").config();
const port = process.env.PORT || 5000;
const app = express();

//middle ware
app.use(cors());
app.use(express.json());

app.get("/", (req, res) => {
  res.send("server is up");
});

app.listen(port, () => {
  console.log("server is running");
});
Comment

Express Server

const express = require("express")

const app = express()

app.listen(5000, () => {
	console.log("Server has started!")
})
Comment

require express server.js

const express = require('express')const app = express() app.get('/', function (req, res) {  res.send('Hello World')}) app.listen(3000)
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript parentnode 
Javascript :: browserrouter react 
Javascript :: regex for entire word 
Javascript :: URL scheme "localhost" is not supported. 
Javascript :: json-server 
Javascript :: check if input is valid 
Javascript :: how to find length of string in javascript without using length method 
Javascript :: select tag onchange 
Javascript :: do not trigger useeffect on start 
Javascript :: Set Custom User Agent react 
Javascript :: json parse array local storage 
Javascript :: opencv4nodejs mac install 
Javascript :: how to write img jsx 
Javascript :: react overflow scroll 
Javascript :: jquery observe class change 
Javascript :: longest word javascript 
Javascript :: onclick checkbox hide div and unchecked show div 
Javascript :: javascript new date 30 days ago 
Javascript :: javascript load multiple images 
Javascript :: javascript remove a specific item from an array 
Javascript :: for each element in object 
Javascript :: jQuery UI Sortable, then write order into a database 
Javascript :: check if over 18 javascript 
Javascript :: convert iso 8601 to utc javascript 
Javascript :: sum javascript 
Javascript :: js get part of array 
Javascript :: js check if function exists 
Javascript :: javascript check if elements of one array are in another 
Javascript :: navigate-to-an-anchor-on-another-page 
Javascript :: javascript clone array of object 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =