Right, the code in the example you gave should do what you want to achieve.
You need to install wrangler following the instructions from https://developers.cloudflare.com/workers/cli-wrangler/install-update
If you haven’t already done this, you will need to run
wrangler login and follow the instructions
If you have done this, then move to the next step:
Next, edit the wrangler.toml with your account ID, the route you want to use and the zone ID (if you want to use a custom domain)