Home/Tutorials/Express/Hello Route

0 of 3 saved

Express5 min read

Hello Route

Read this chapter, write the program on this page, then pass a short check to open the next one.

Your first GET handler.

Hello Route

A route matches a method + path. The handler receives req and res. Send JSON with res.json or text with res.send.

  • app.get("/", (req, res) => res.send("ok"))
  • Status defaults to 200 unless you set otherwise.
  • Keep handlers thin — call services for logic.
const path = "/";
const method = "GET";
console.log(method, path, "ok");

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.