ES6语法

佚名2020-02-25编程 1889°  0
不添加 .js 的后缀名会报找不到module错误GET xxx net::ERR_ABORTED 404 (Not Found)import { Student } from './Student.js';导入导出方式1.导出方式定义时导出批量导出导出重命名(不建议)默认导出 // 1.定义时导出 export let uname = '李四'; export function showStudentName(){ console.log(uname); } export class SomeAnimalInfo{

2的N次幂表

佚名2020-04-12数学 6739°  0
20593922^174=239452428260295134118491722992235809940427987841187842^175=478904856520590268236983445984471619880855975682375682^176=957809713041180536473966891968943239761711951364751362^177=1915619426082361072947933783937886479523423902729502722^178=3831238852164722145895867567875772959046847805459

nodejs使用Phantomjs爬取动态页面

佚名2020-05-24编程 1995°  0
:向response中发送响应头部。 statusCode 是一个3位数字,表示HTTP状态码(如404)。后一个参数代码响应头部close() :关闭HTTP连接 为了避免客户端检测到连接中断,记得最后再用write()方法发送一个空字符串(如:response.write(""))。closeGracefully() :功能与 close() 一样,不过更安全可靠,它能保证响应头部先发送,并自动在响应最后加上 response.write("")

nginx直接在配置文件中设置日志分割

佚名2023-10-20软件 2136°  0
~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm7.sock; } }直接在nginx配置文件中,配置日志循环,而不需使用logrotate或配置cron任务。需要使用到timeiso8601内嵌变量来获取时间。time_iso8601 内嵌变量来获取时间。timeiso8601内嵌变量来获取时间。time_iso8601格式如下:2015-08-07T18:12:02+02

nodejs读取图片返回给浏览器显示

佚名2021-06-06编程 1663°  0
js的fs.readFile来处理。根据请求地址,转换成实际的文件地址。判断文件是否存在,不存在返回404,存在则读取文件 ,并返回文件。//设置请求的返回头type,content的type类型列表见上面response.setHeader("Content-Type", contentType);//格式必须为 binary 否则会出错var content = fs.readFileSync(url,"binary");response.writeHead(200, "Ok");response.write(content,"binary"); //格式必须为 binary,否则会出错

当客户端想要下载文件时,nodejs服务端如何根据URL设置响应头的Content-Type类型

佚名2021-06-06编程 1720°  0
ntent-Type':'text/plain'}); res.status(404).send("Bad Request"); return; }else{ var suffix=filename.split(".")[1];//去除文件名的后缀 suffix="."+suffix;//由于字符串是根据“.”分隔,如app.js分隔成js,所以要加上点 getRightType(suffix).then( (typ

nodejs的缓存文件和使用进程

佚名2021-06-06编程 1673°  0
at)=>{ if(err){ res.writeHeader(404); res.write("Not Found"); res.end(); }else{ //判断客户端的请求头里面是否有if-modified-since if(req.headers["if-modified-since"]){ //获取客户端和服务端文件的修改时间 let cDate = new Date(req.head

nodejs简易Socket.io聊天室开发

佚名2021-06-29编程 1474°  0
f (error) { response.writeHead(404); response.write("page doesn't exist - 404"); response.end(); } else { response.writeHead(200, { "Content-Type": "text/html" }); response.w

nginx在使用proxy_pass的情况下开启error_page

佚名2019-05-09软件 3128°  0
_timeout 3;然后再每一个域名.conf下增加错误码跳转:error_page 404 = http://m.test.com;error_page 500 502 503 504 /50x.html;

NodeJS框架express的路径映射(路由)功能及控制

佚名2019-05-13编程 1839°  0
get('*', function(req, res){ res.send('what???', 404);});app.listen(3000);路由参数预处理路由参数预处理通过隐式的数据处理,可以大幅提高应用代码的可读性和请求URL的验证。假如你经常性的从几个路由获取通用数据,如通过/user/:id加载用户信息,通常我们可能会这样做:app.get('/user/:userId', function(req, res, next){ User.get(req.params.userId, function(err, user){ if (err) return next(er