【发布时间】:2022-07-12 01:27:16
【问题描述】:
我无法在 express 应用中包含静态 CSS 文件
我已经在输出文件 CSS 中使用了 app.use(express.static('public') in not include
// initialize modules // ATHARVA BHAVSAR
const express = require("express");
const bodyParser = require("body-parser");
const request = require("request");
//creating app from express method
const app = express();
//body parser
app.use(bodyParser.urlencoded({ extended: true }));
//including static files in the app
app.use(express.static("public"));
//get method for the app
app.get("/", (req, res) => {
res.sendFile(__dirname + "/signup.html");
});
//post method for the app
app.post("/", (req, res) => {
//getting the entries from the user
const FirstName = req.body.Fname;
const LastName = req.body.Lname;
const Email = req.body.email;
//trial
console.log(FirstName, LastName, Email);
});
//listening to port 3000
app.listen(3000, function () {
console.log("Server is running on port 3000");
});
【问题讨论】: