Node.js

来源:互联网 发布:c语言中各类数据 编辑:程序博客网 时间:2024/06/06 00:28
const http = require('http');//建立http请求const hostname = '127.0.0.1';const port = 3000;//req:请求内容;res:响应内容const server = http.createServer((req, res) => {//创建一个web服务器  res.statusCode = 200;  res.setHeader('Content-Type', 'text/plain');  res.end('Hello World\n');});server.listen(port, hostname, () => {//服务器在3000端口监听请求  console.log(`Server running at http://${hostname}:${port}/`);});
原创粉丝点击