wordpress能做图片站,网站开发费用多少,邯郸网站建设效果好,高端网站设计定制公司如果用PHP来编写后端代码#xff0c;需要用Apache或者Nginx的服务器,来处理客户的请求响应。对于Node.js时#xff0c;不仅实现了应用#xff0c;同时还实现了整个HTTP服务器.
安装 Node Snippets插件#xff08;编程自带提示#xff09; console.log(你好nodejs);
//表…如果用PHP来编写后端代码需要用Apache或者Nginx的服务器,来处理客户的请求响应。对于Node.js时不仅实现了应用同时还实现了整个HTTP服务器.
安装 Node Snippets插件编程自带提示 console.log(你好nodejs);
//表示引入http模块
var http require(http);
/*
request 获取url传过来的信息
response 给浏览器响应信息
*/
http.createServer(function (request, response) {//设置响应头response.writeHead(200, {Content-Type: text/plain});//表示给页面上面输出一句话并且结束响应response.end(Hello World!);
}).listen(8081);//端口console.log(Server running at http://127.0.0.1:8081/);//引入http模块
const httprequire(http);//http.createServer((req,res){
http.createServer(function (req,res) {//req 获取客户端传过来的信息//res 给浏览器响应信息console.log(req.url);//获取url//设置响应头//状态码是200文件类型是html,字符集是utf-8res.writeHead(200,{Content-type:text/html;charsetutf-8}); //解决乱码res.write(headmeta charsetUTF-8/head); //如果没有这一行下面的 你好 是乱码 //解决乱码res.write(this is nodejs);res.write(你好 nodejs);res.end();//结束响应如果没有这一行浏览器左上角的图标一直在转圈
}).listen(3000); //端口建议3000以上防止冲突总结
引入http模块 var httprequire(“http”)