Есть add.html:
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Add new user</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" >
<link rel="stylesheet" href="/css/style.css" type="text/css" />
</head>
<body>
<div id="form" class="b_form">
<form action="/register" method="POST">
<div class="f_item f_title">Add USER</div>
<div class="f_item"><input type="text" name="uName" placeholder="Enter your name" value=""></div>
<div class="f_item"><input type="text" name="uLogin" placeholder="Enter your login" value=""></div>
<div class="f_item"><input type="submit" value="Submit"></div>
</form>
</div>
</body>
</html>
Есть app.js:
const express = require("express"),
path = require("path"),
bodyParser = require("body-parser");
const app = express();
const urlencodedParser = bodyParser.urlencoded({extended: false});
app.use(express.static(__dirname + '/public'));
app.post("/register", urlencodedParser, function (request, response) {
if(!request.body) return response.sendStatus(400);
console.log(request.body);
response.send(`${request.body.uName} - ${request.body.uLogin}`);
});
app.get("/", function(request, response){
response.send("<h1>Главная страница</h1>");
});
app.get('/register', function(req, res) {
res.sendFile(path.resolve(__dirname, 'register.html'));
});
app.listen(3000);
Как заставить работать файл style.css?
При открытии напрямую:
Cannot GET /css/style.css