Skip to content

Commit

Permalink
First http server
Browse files Browse the repository at this point in the history
  • Loading branch information
dqj1998 committed Jul 30, 2022
1 parent 8fddde5 commit c4c12f0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const http = require("http");
const port = 3000;

const server = http.createServer((request, response) => {
const url = new URL(request.url, `http://${request.headers.host}`)

response.writeHead(200, {
"Content-Type": "text/html"
});

const responseMessage = "<h1>Hello World, dqj1998</h1>";
response.end(responseMessage);
console.log(`Responsed : ${responseMessage}`);
});

server.listen(port);
console.log(`Started server: ${port}`);

0 comments on commit c4c12f0

Please sign in to comment.