Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 :: react route props 
Javascript :: react propthpes or 
Javascript :: node red debug to console 
Javascript :: for each array 
Javascript :: how to make an event listener only work once 
Javascript :: Slice and Splice -Javascript 
Javascript :: js initialize 2d array 
Javascript :: brython.js download 
Javascript :: proxy api javascript get 
Javascript :: play audio in react 
Javascript :: what is new set in javascript 
Javascript :: Match an object in a string using ReGex 
Javascript :: javascript timestamp 
Javascript :: javascript navigator.mediaDevices.getUserMedia 
Javascript :: sortable jquery 
Javascript :: clearinterval in javascript 
Javascript :: jquery syntax 
Javascript :: flatMap() method 
Javascript :: to show which tab is active in VueJS 
Javascript :: jquery label with text 
Javascript :: use useRef to get current class 
Javascript :: documentation tool for angular applications 
Javascript :: format iso time in human readable format with moment js 
Javascript :: navigate json object javascript 
Javascript :: Adding whitespace to the left of the string in JavaScript 
Javascript :: create video playlist using jquery 
Javascript :: momentum 
Javascript :: js get last n elements of array 
Javascript :: datatable add filter dropdown 
Javascript :: loop through async javascript -3 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =