一.node.js中基本的响应信息

2021-08-12 21:58

阅读:690

标签:基本   发送   dir   字符串   down   响应   lis   res   express   const express = require("express"); //创建服务器 var app = express(); //配置服务器的端口 app.listen(8080); app.get("/login",(req,res)=>{ //普通响应 // res.end("今天天气好晴朗!") //处理请求头 // res.send("登录页面"); //模板字符串 // res.send(` // // 这是模板字符串 // // `); //发送文件 // res.sendFile(__dirname+"/static/index.html"); //重定向 // res.redirect("https://www.cnblogs.com/Listener-wy/") //JSON格式响应 // res.json({name:"张三",sex:"男",age:18}); // 响应下载 // res.download(__dirname+"/static/index.html"); //设置响应的请求头,设置完毕之后,需要响应,否则,浏览器接收 // res.set("name","wenyuan"); // res.end("this is my house"); //设置响应的状态码 // res.status(404); // res.send("this is my house"); }) 一.node.js中基本的响应信息标签:基本   发送   dir   字符串   down   响应   lis   res   express   原文地址:https://www.cnblogs.com/Listener-wy/p/14863960.html


评论


亲,登录后才可以留言!