Created
April 6, 2017 12:18
-
-
Save junsuk5/c9928404417b59a9dded1a74c3baa35c to your computer and use it in GitHub Desktop.
Node express sample
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() | |
| app.get('/', function (req, res) { | |
| res.send('Hello World') | |
| }) | |
| app.get('/user/:id', function (req, res) { | |
| res.send('GET ' + req.params.id); | |
| }); | |
| app.post('/user', function (req, res) { | |
| res.json({ | |
| success: true | |
| }); | |
| }); | |
| app.put('/user', function (req, res) { | |
| res.status(400).json( | |
| { | |
| message: 'Bad Request' | |
| } | |
| ) | |
| }) | |
| app.delete('/user', function (req, res) { | |
| res.send('DELETE'); | |
| }) | |
| app.listen(3000, function () { | |
| console.log('Server Started'); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment