效果:
代码:
var http=require(‘http‘); var fs=require(‘fs‘); var path=require(‘path‘); var mime=require(‘mime‘); var cache={}; var server=http.createServer(function(request,response){ response.writeHead(200,{‘Content-Type‘:‘image/png‘}); fs.createReadStream(‘./public/img/jkx.png‘).pipe(response); } ); server.listen(3000,function(){ console.log(‘Server is listenning on port 3000.‘); });
代码下载:
https://files.cnblogs.com/files/xiandedanteng/nodejsImageSend.rar
时间: 2024-10-10 08:12:50