Exercise #02 - Echo
Write a server that exposes a /echo
route.
Return the body of the request as the response.
POST /echo some string >>> expected "some string" POST /echo Show me your types and I'll tell you who you are >>> expected "Show me your types and I'll tell you who you are"
It looks like your server isn't up. This page expects your Haskell application to be listineing on
http://localhost:7879.
If you're unsure on how to proceed, read more on how to setup your Local dev environment to complete the exercises.
If you're unsure on how to proceed, read more on how to setup your Local dev environment to complete the exercises.
Refresh the page to run the tests again.
Reference node.js implementation
const app = require("express")()
const bodyParser = require("body-parser")
app.use(bodyParser.raw({ type: "*/*" }))
app.post("/echo", (req, res) => {
res.send(req.body.toString())
})
console.log("Starting server...")
app.listen(7879)
Walkthrough video
Here's a video of me going through the exercise, from scratch! 🌵
Where to get help
Got stuck? Don't worry! Join the discussion on Github (issue #2). It might be that the exercise could be clearer or there's something you really can't wrap your head around. That's totally fine! 🙂
You can also have a look at my solution. No shame in having a peek. 🧐
But do share your thoughts on the exercises, it would be really helpful!