generated from skills/copilot-codespaces-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f32d86
commit ce125fd
Showing
1 changed file
with
4 additions
and
54 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,8 @@ | ||
// create web server | ||
const express = require('express'); | ||
// create web server | ||
const app = express(); | ||
// create web server | ||
const port = 3000; | ||
|
||
// create web server | ||
app.get('/comments', (req, res) => { | ||
res.send('Comments'); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is listening on port: ${port}`); | ||
}); | ||
``` | ||
```javascript | ||
// Path: posts.js | ||
// create web server | ||
const express = require('express'); | ||
// create web server | ||
const app = express(); | ||
// create web server | ||
const port = 3000; | ||
|
||
// create web server | ||
app.get('/posts', (req, res) => { | ||
res.send('Posts'); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is listening on port: ${port}`); | ||
}); | ||
``` | ||
```javascript | ||
// Path: index.js | ||
// create web server | ||
const express = require('express'); | ||
// create web server | ||
const app = express(); | ||
// create web server | ||
const port = 3000; | ||
|
||
const comments = require('./comments'); | ||
const posts = require('./posts'); | ||
|
||
// create web server | ||
app.use('/comments', comments); | ||
app.use('/posts', posts); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is listening on port: ${port}`); | ||
}); | ||
``` | ||
app.use(express.json()); | ||
|
||
### | ||
// create a comments array | ||
const comments = [ | ||
{ username: 'alice', comment: 'I love this |