“Utwórz serwer WebServer w JavaScript” Kod odpowiedzi

Jak utworzyć serwer w węźle 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

Utwórz serwer WebServer w 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

Odpowiedzi podobne do “Utwórz serwer WebServer w JavaScript”

Pytania podobne do “Utwórz serwer WebServer w JavaScript”

Więcej pokrewnych odpowiedzi na “Utwórz serwer WebServer w JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu