Skip to content

Commit 0773c03

Browse files
committed
Changes for repl.it
1 parent edd8a00 commit 0773c03

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.replit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
language = "nodejs"
2+
run = "npm run repl"

app.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const http = require('http');
22

3-
const hostname = '127.0.0.1';
3+
//const hostname = '127.0.0.1';
44
const port = 3000;
55

66
const server = http.createServer((req, res) => {
@@ -12,14 +12,15 @@ const server = http.createServer((req, res) => {
1212
"items": [
1313
"str1",
1414
"str2",
15-
"str3"
15+
"str3",
16+
"str4"
1617
]
1718
};
1819
const { headers, method, query, url } = req;
1920
const responseBody = { headers, method, query, url, body };
2021

2122
res.write(JSON.stringify(responseBody));
2223
res.end();
23-
}).listen(port, hostname, () => {
24-
console.log(`Server running at http://${hostname}:${port}/`);
24+
}).listen(port, () => {
25+
console.log(`Server running at ${port}/`);
2526
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Demo JSON API.",
55
"main": "app.js",
66
"scripts": {
7+
"repl": "node app.js",
78
"dev": "nodemon app.js",
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},

server.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const express = require('express');
22

33
const app = express();
44

5-
const hostname = '127.0.0.1';
5+
//const hostname = '127.0.0.1';
66
const port = 3000;
77

88
app.get('/', (req, res) => {
@@ -13,7 +13,8 @@ app.get('/', (req, res) => {
1313
"items": [
1414
"str1",
1515
"str2",
16-
"str3"
16+
"str3",
17+
"Hello, world in item 4"
1718
]
1819
};
1920
const { headers, method, query, url } = req;
@@ -22,6 +23,6 @@ app.get('/', (req, res) => {
2223
res.send(JSON.stringify(responseBody));
2324
})
2425

25-
app.listen(port, hostname, () => {
26-
console.log(`Example app listening at http://${hostname}:${port}`);
26+
app.listen(port, () => {
27+
console.log(`Example app running at ${port} port`);
2728
})

0 commit comments

Comments
 (0)