this is a simple app built to enable simple statistics on url traffic (mainly for QR codes). It was build in rust on cloudflare's serverless workers platform.
it was cloned from the cloudflare/workers-sdk/templates/experimental/worker-rust repository, and made by following this tutorial.
the app only has a handful of routes that it serves, so here's an outline. routes are defined in src/lib.rs
the index page is a simple landing page, which explains how the app works and allows the user to create a redirect for their URL, as well as an optional password to secure their stats, as well as some other configuration. this is managed via a simple HTML form, which POSTs the request to a qrstats-worker, and is handled there.
a form for creating a new tracked URL. requires a URL, and optionally accepts a custom ID and password.
sends the data from the form on the above page to the server to be added to the KV store. returns either views::create_success
or views::create_error
fetches the URL for the given ID, increments the saved count for that tracked URL, and issues an HTTP Redirect response to the stored URL.
this page allows the user to "login", either via their id along with an optional password.
this returns the stats for the ID from the form above.
this attempts to authenticate, and either returns a similar response to POST /stats, or redirects to the GET /stats login page.