Loading

T8 Node.js · Lesson 6

Games: An HTTP server

Choose the right option, fill in the blanks, write small pieces of code and fix broken ones. Code runs in a safe box inside this page.

Solved 0 of 47 items in this lesson.

1 / 23

This program is a server and its own client, run in the shop's folder. What does it print?

cat > app.js <<'END'
const http = require("http");
const server = http.createServer(async (req, res) => {
  res.statusCode = 201;
  res.end();
});
server.listen(3000, async () => {
  const r = await fetch("http://localhost:3000/");
  console.log(r.status, r.statusText);
  server.close();
});
END
node app.js

Back to the lesson