惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - kylindai

Spark installation for windows java cpu load - kylindai remove all .git files and directories use one command - kylindai Android adb not responsing putty ssh login linux nodejs 实现 http proxy 透明转发 mybatis 处理数组类型及使用Json格式保存数据 JsonTypeHandler and ArrayTypeHandler 一次PostgreSql数据迁移,使用nodejs来完成 nodejs 安装 postgresql module mongodb 安装为windows服务 memcached linux / win32 1.4.13 learning nodejs 2 - connect middleware javascript的变量、作用域和内存问题 javascript编程的最佳实践推荐 android download host jetty-distribution-7.6.x 部署 Quartz Cron 表达式 ImageMagick 批量处理图片脚本 常用 LINUX 命令
learning nodejs 1 - stream.pipe
kylindai · 2014-01-17 · via 博客园 - kylindai
a simple http server using inner http module.
var http = require('http');
var fs = require('fs');

// 这是一个很有趣的包 require(
'colors'); var server = http.createServer(function(req, res) { if ('GET' == req.method && '/images' == req.url.substr(0, 7) && '.jpg' == req.url.substr(-4)) { console.log(req.url.red); console.log((__dirname + req.url).red); fs.stat(__dirname + req.url, function(err, stat) { if (err || ! stat.isFile()) { res.writeHead(404); res.end('Not found'); return; } serve(__dirname + req.url, 'image/jpg'); }); } else if ('GET' == req.method && '/' == req.url) { serve(__dirname + '/index.html', 'text/html'); } else { res.writeHead(404); res.end('Not found'); } function serve(path, type) { console.log(path.yellow); console.log(type.red); res.writeHead(200, {'Content-Type': type});

// 这个是亮点,流的管道方法,类似C++的 << fs.createReadStream(path).pipe(res); } }).listen(

3000);