如题所述
使ç¨node.jsçæjsonæ°æ®ä»£ç å¦ä¸ï¼
var http = require('http');var data = {key: 'value', hello: 'world'};
var srv = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(data));
});
srv.listen(8080, function() {
console.log('listening on localhost:8080');
});
温馨提示:答案为网友推荐,仅供参考