企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
(1)response.redirect方法 response.redirect方法允许网址的重定向。 ~~~ response.redirect("/hello/anime"); response.redirect("http://www.example.com"); response.redirect(301, "http://www.example.com"); ~~~ (2)response.sendFile方法 response.sendFile方法用于发送文件。 ~~~ response.sendFile("/path/to/anime.mp4"); ~~~ (3)response.render方法 response.render方法用于渲染网页模板。 ~~~ app.get("/", function(request, response) { response.render("index", { message: "Hello World" }); }); ~~~ 上面代码使用render方法,将message变量传入index模板,渲染成HTML网页。