📜  在 javascript 代码示例中创建网络服务器

📅  最后修改于: 2022-03-11 15:03:50.493000             🧑  作者: Mango

代码示例2
// 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