Created
May 17, 2017 07:16
-
-
Save nandunbandara/75c9119db32e783daeaa0affe5892fc7 to your computer and use it in GitHub Desktop.
Sample express service
This file contains 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
const express = require("express") | |
bodyParser = require("body-parser"); | |
app = express(); | |
app.use(bodyParser.urlencoded({ extended:false })); | |
app.use(bodyParser.json()); | |
app.get('/', (req,res)=>{ | |
res.json({message: "sample service"}); | |
}) | |
app.post('/', (req,res)=>{ | |
res.json({received:req.body, status:"success"}); | |
}) | |
app.get('/:id', (req,res)=>{ | |
res.json({recieved:req.params.id, status:"success"}); | |
}) | |
app.listen(9001, ()=>{ | |
console.log("Listening on port 9001"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment