如何处理Express.js中的路由以及有多少方法可以通过代码和demo.answer通知我,谢谢。谢谢
答案 0 :(得分:2)
我写过a longer guide that explains this stuff,但这是一个简单的例子:
var express = require("express");
var app = express();
app.get("/", function(request, response) {
response.send("Welcome to the homepage!");
});
app.get("/about", function(request, response) {
response.send("Welcome to the about page!");
});
app.get("*", function(request, response) {
response.send("404!");
});
app.listen(1337);