🛰️ live

Porting a Flask app to the edge.

"What's my IP" sounds like a one-liner. A good one is a surprisingly complete network checkup.

•field note
What Is My IP page showing an example IPv4 address, connectivity checks and IP details
The address shown is a documentation example; yours will be your own.

The University of North Carolina publishes a really nice "what is my IP" tool. It doesn't stop at the address: it checks IPv6, figures out which DNS resolver you're actually using, tests whether DNS filtering is in place, and can print a tidy report to send to whoever is helping you debug.

Why port it

The original is a Flask app, which means a server to run and patch. Most of what it does is look at the incoming request and ask a few lookup services questions, which is exactly what Cloudflare Workers are good at. Moving it to the edge means no server, the request details come for free, and it answers from a data center near whoever is asking.

Same tool, no server to babysit.

How it came together

  • The Jinja2 templates moved to Nunjucks, a near-exact JavaScript port, and render once at build time instead of on every request.
  • The few values that really change per visitor, like your address, are injected at the edge with Cloudflare's HTMLRewriter.
  • The Python routes became a single Worker, with a small D1 database for aggregate page stats.
  • The front end (map, connectivity checks, speed test, printable report) stays as close to upstream as possible.

What didn't make the trip

The original is a campus tool, so it enriches university addresses from internal systems: IP address management, network access control, building lookups, wireless access points. None of that is reachable from the public edge, so those features were dropped, while the API keeps its original shape so the front end doesn't notice.

What I took away

Porting is a great way to read someone else's code closely. You find out which parts are essential and which were just habits of the original platform. Credit where it's due: the hard thinking about what a good IP checker should show was UNC's. (This port isn't affiliated with or endorsed by UNC.)