Live2d Test Env

node原生服务器


/*
 * @Descripttion:
 * @version:
 * @Author: jack
 * @Date: 2022-03-07 22:18:09
 * @LastEditors: jack
 * @LastEditTime: 2022-03-07 22:37:57
 */
// 导入http模块
const http = require("http");
const app = http.createServer((req, res) => {
  // req:请求对象:一些参数以及请求体
  // res:响应对象:返回给前端的数据
  // 设置响应头
  res.writeHead(200, { "Content-Type": "text/plain;charset=utf-8" });
  // 设置返回数据
  res.end(`欢迎学习node.js`);
});
const port = 9990;
app.listen(port, () =>
  console.log(`监听了9990,成功,运行在  http://127.0.0.1:${port}`)
);

posted @ 2022-03-07 22:39  致爱丽丝  阅读(34)  评论(0)    收藏  举报