Created
May 9, 2013 01:18
-
-
Save sunkay/5544882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'); | |
| var app = express(); | |
| var devices = [ | |
| {id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"}, | |
| {id:1, name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""}, | |
| {id:2, name: "loaner-laptop-3", assetTag:"a43056", owner:"qa", desc:""}, | |
| {id:3, name: "android", assetTag:"a33756", owner:"dev", desc:"android2.4"}, | |
| {id:4, name: "galaxy tab", assetTag:"a53356", owner:"dev", desc:"android"}, | |
| {id:5, name: "loaner-laptop-2", assetTag:"a63556", owner:"qa", desc:""}, | |
| {id:6, name: "iphone", assetTag:"a73856", owner:"dev", desc:"iOS5"} | |
| ]; | |
| // Read | |
| app.get('/devices', function(req, res) { | |
| res.send(devices); | |
| }); | |
| // View one device | |
| app.get('/device/:id', function(req, res) { | |
| res.send(devices[req.params.id]); | |
| }); | |
| app.listen(3000); | |
| console.log('Listening on port 3000...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment