Showing
1 changed file
with
11 additions
and
4 deletions
| 1 | const http = require('http'); | 1 | const http = require('http'); |
| 2 | 2 | ||
| 3 | -const server = http.createServer(); | 3 | +const server = http.createServer((req,res) => { |
| 4 | + if (req.url === '/') { | ||
| 5 | + res.write('Hello World'); | ||
| 6 | + res.end(); | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + if(req.url === '/api/courses') { | ||
| 10 | + res.write(JSON.stringify([1,2,3])); | ||
| 11 | + res.end(); | ||
| 12 | + } | ||
| 13 | +}); | ||
| 4 | 14 | ||
| 5 | -server.on('connection',(socket) => { | ||
| 6 | - console.log('New Connection...'); | ||
| 7 | -} ); | ||
| 8 | 15 | ||
| 9 | server.listen(3000); | 16 | server.listen(3000); |
| 10 | 17 | ... | ... |
-
Please register or login to post a comment