01-18 12:00
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[Web App/Node.js Express] JSON 본문

Programming/Web App

[Web App/Node.js Express] JSON

cinema4dr12 2014. 9. 8. 17:10

[app.js]

app.use('/', routes);


[index.js]

var express = require('express'); var router = express.Router();

var users = ['choi', 'kim','park', 'lee', 'cho']; router.get('/users/:from-:to', function(req, res){ var from = parseInt(req.params.from, 10), to = parseInt(req.params.to, 10); res.json(users.slice(from, to + 1)); }); module.exports = router;


Comments