node笔记 -01

news/2024/7/19 15:51:52 标签: js

一、http模块、url模块、supervisor工具

http模块
var http = require(‘http’);

http.createServer(function(request, response){
response.writeHead(200, {’'Content-Type": “text/plain”});
response.end(“hello world”);
}).listen(8081);

http.createServer // 创建应用
request // 浏览器传到应用的信息
response // 给浏览器响应信息

writeHead // 设置响应头
end // 页面上输出 并且结束响应应用
listen(num) num // 端口

服务器解决乱码: response.writeHead(200, {’‘Content-Type": “text/html;charset=‘utf-8’”})
浏览器解决乱码: response.write(’’)

URL模块
url.parse(); 解析地址 接收两个参数 (api, boolean) boolean是否要将参数转话为json格式

supervisor
自动加载服务端工具
cnpm install supervisor -g
一般是node app.js
那么就用supervisor app.js


http://www.niftyadmin.cn/n/1579467.html

相关文章

ios 7 transition

2019独角兽企业重金招聘Python工程师标准>>> the main themes of ios 7: Deference. The UI helps users understand and interact with the content, but never competes with it. Clarity. Text is legible at every size, icons are precise andd lucid, adorn…

react笔记-01

1、服务代理 在package.json设置 "proxy": "代理地址" 2、antd的使用和less的引入 [https://ant.design/docs/react/use-with-create-react-app-cn](里面可以顺便引入less, 最好就不要使用package的cnpm eject,除非你…

不同的风格

没有什么是完全一样的。转载于:https://blog.51cto.com/cornerme/1222676

egg.js笔记

1、连接mongo数据库的配置 01----关于mongoDB cnpm install egg-mongoose egg-mongo-native -S 具体下的东西作用是什么,自行npm官网查好一点 // config.default.js // mongo数据库连接config.mongoose {client: {url: mongodb://127.0.0.1/project,options: {},…

MySQL集群安装与配置

MySQL Cluster 是 MySQL 适合于分布式计算环境的高实用、高冗余版本。它采用了NDB Cluster 存储引擎,允许在1个 Cluster 中运行多个MySQL服务器。MySQL Cluster 能够使用多种故障切换和负载平衡选项配置NDB存储引擎,但在 Cluster 级别上的存储引擎上做这…

ElementUI按需合并列

vue elementUI按需合并列 https://www.cnblogs.com/jun-qi/p/11052634.html大神的提示 加上 自己的一点点点的小改动 这是我的数据结构 这里将数据结构传入到要改造数据的方法里 研究了一下午 虽然很长时间 吸收了知识就是大事 皇天不负有心人

学习环境搭建之Vmware player putty

下载linux的vmware版本,懒的安装,下了backtrack5虚拟版本,网络设置桥连接或NAT连接,ssh开启等等。 可以ping通,但putty连接报软件错误,我还以为是putty版本问题,经测试不是。后来backtrack ssh连…

flutter安装踩坑日记

当你遇到系统找不到指定的路径。 你没得选,重装flutter 当你遇到! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses flutter doctor --android-licenses疯狂选y