The request-response cycle
Understand the idea
A server waits, reads one request, and writes one response.
The idea
http.createServer registers the function that runs for each request. req is what arrived. res.end is the body you send back. No framework is involved yet. That is the point.
What changes
| Step | Object | What you do |
|---|---|---|
| Arrive | req | Read the method and the path |
| Answer | res | Write a status and end the body |
| Stop | the process | This runner closes after one request |
The command
Hello World
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The bar above the body is the one request the harness sent to 127.0.0.1. It is not a site you can browse.
The mistake
Check the result
Status 200 and the body Hello World. Run it again and you get a new process, not the same one still listening.
Guided challenge
Answer with Hello World
The handler currently ends the response with Ping. Change the body to Hello World for GET /.
Answer with Hello World
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
status 200 Hello World
Hints 0/2
Use all hints or make 3 failed checks (0/3).
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 100 XP. You can always revisit it.