“Crea un servidor web en JavaScript” Código de respuesta

Cómo crear un servidor en el nodo JS

// code by VARSHITH REDDY SATTI
// to create a server in node.js you should.
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write("write html code to display you test")
  res.end();
}).listen(8080);
// save this as httpServer.js
// run this by typing node httpServer.js in the command line
// to acess your server got to http://localhost:8080
Crown Of Thorns Starfish

Crea un servidor web en JavaScript

// Install Express First ( npm install express )
// Code By Asim
const express = require("express")
const app = express()
app.get("/", (req, res) => { // Replace "/" with The Link You Want
	res.send("Hello World !")
})
app.listen(3000, console.log("Listening In Port 3000") // 3000 Is The Port ( Change It If You Want )
// Want To Add Html ?
// Replace Line 6 with: res.send(`Type Your Html Here `)
// Or Just Use View Engine Like ejs .
// Save This File WIth Any name: index.js
// and run it with command: node (YourFileName) like this: node index.js
// Go To Your Server By Typing In Browser: localhost:(Your Port) like this: localhost:3000
Evil Elephant

Respuestas similares a “Crea un servidor web en JavaScript”

Preguntas similares a “Crea un servidor web en JavaScript”

Más respuestas relacionadas con “Crea un servidor web en JavaScript” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código