Middleware examples
This commit is contained in:
@@ -7,7 +7,7 @@ const app = express();
|
||||
const bodyParser = require("body-parser");
|
||||
app.use(bodyParser.urlencoded({extended:false}));
|
||||
|
||||
app.use("/", (req, res) => {
|
||||
app.use("*", (req, res) => {
|
||||
console.log(req.query, req.body);
|
||||
res.send("Server alive, with Express!");
|
||||
});
|
||||
|
||||
@@ -15,6 +15,11 @@ app.get(
|
||||
})
|
||||
);
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
console.error("Error....", err.message);
|
||||
res.status(500).send("INTERNAL SERVER ERROR");
|
||||
});
|
||||
|
||||
app.listen(8080, () =>
|
||||
console.log(
|
||||
"Mini Express static server ready at http://localhost:8080/!"
|
||||
|
||||
Reference in New Issue
Block a user