const express = require("express");
//创建服务器
var app = express();
//配置服务器的端口
app.listen(8080);

app.get("/login",(req,res)=>{
    //普通响应
    // res.end("今天天气好晴朗!")

    //处理请求头
    // res.send("登录页面");

    //模板字符串
    // res.send(`
    //     <ul>
    //         <li>这是模板字符串</li>
    //     </ul>
    // `);

    //发送文件
    // 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");
})
posted on 2021-06-08 18:25  文种玉  阅读(186)  评论(0编辑  收藏  举报