Skip to content
engineering workbench.by StudyPort Academy
Learning path
Intermediate16 min

Why a framework

Understand the idea

Express is the routing and response work you would otherwise write by hand.

The idea

The first panel is the cycle by hand. The second is the same answer through . app.get matches method and path. res.send writes the body. You did not call writeHead yourself.

What changes

Raw Node and Express
VersionWho matches the pathWho writes the body
Raw http.createServerYour if statementres.end
Express app.getThe routeres.send
BothStill one requestStill one response

The command

Raw Node

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.

Express route

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 mistake

Check the result

Both bars show 200 and Hello. The Express file is shorter because the match moved into the route.

Guided challenge

Send Hello from the Express route

GET /hello currently sends Hi. Change the route so the body is Hello.

Send Hello from the Express route

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

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.

    01What does the Express version avoid writing?
    02What stayed the same?

    Ready to call this one understood?

    Mark this lesson complete to earn 150 XP. You can always revisit it.

    Sign in to save progress
    Next lesson