分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

第一个nodejs程序

发布时间:2023-09-06 01:40责任编辑:赖小花关键词:jsnodejs

1、用任意文本编辑工具,如notepad++,编写如下代码,保存为test.js文件:

var http=require(‘http‘);http.createServer(function (request,response){ ???????response.writeHead(200,{‘Conten-Type‘:‘text/plain‘})response.end("Hello,world\n");}).listen(8887);console.log(‘Server running at http://127.0.0.1:8887‘) 

  

2、打开cmd,运行该文件,命令 node D:\nodetest\service\test.js,弹出如下页面

3、在浏览器中输入http://127.0.0.1:8887/,结果如下:

是不是超级简单呢!!!

第一个nodejs程序

原文地址:https://www.cnblogs.com/stin/p/8391240.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved