Manual Routing
Without a framework, "routing" just means writing conditional logic that inspects req.url and req.method, and responds differently based on what it finds.
A Server With Basic Routes
Try it yourself — edit and run
Console Output
Click “Run” to see the console output here.
Reading a Request Body
The request body arrives as a stream of Buffer chunks, not as a ready-made value — you have to collect and parse it yourself when building directly on http, which frameworks handle for you automatically.
Parsing a JSON Request Body
Try it yourself — edit and run
Console Output
Click “Run” to see the console output here.
Common HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 400 | Bad Request |
| 404 | Not Found |
| 500 | Internal Server Error |
Best Practice
Seeing how much manual work goes into routing and body parsing with raw http is exactly why real projects use a framework like Express — it replaces all of this boilerplate with a few lines of declarative route definitions.