NodeJS HTTP Server with Express

pligin

Команда форума
Администратор
JavaScript:
const express = require("express");
const app = express();
const port = 8080;

app.use("/public",express.static(__dirname + "/public"));

app.listen(port, () => {
  console.log("Application started and Listening on port "+port);
});

app.get("/", (req, res) => {
  res.sendFile(__dirname + "/index.html");
});
/public - for static
index.html - in the root directory
 
Верх