-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pinging the server at 127.0.0.1 when using just the port number (#…
…357) * add 0.0.0.0 server ci example * add explicit zero test * add timeout to the waiting failing demo * add test and explanation * run more tests in Node v16 * add debugging * update what we run on node v16 * switch from localhost to 127.0.0.1 for default host * prepend localhost and common host names with http * update readme * ipv6 test * update localhost in README snippets
- Loading branch information
Showing
7 changed files
with
136 additions
and
32 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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import http from 'node:http'; | ||
|
||
// Create a local server to receive data from | ||
const server = http.createServer(); | ||
|
||
// Listen to the request event | ||
server.on('request', (request, res) => { | ||
console.log('server responding') | ||
res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
res.end(JSON.stringify({ | ||
data: 'Hello World!', | ||
})); | ||
}); | ||
|
||
server.listen(8000, '0.0.0.0', () => { | ||
console.log('server is listening on 0.0.0.0:8000') | ||
}); |