Template
1
Fork 0
ip-lookup/README.md
Leonardo Devai 2ecdbbe1f6 Review and modernize all 42 projects to the updated standard
Pinned 2026 toolchains (Go 1.26, Rust 1.98/edition 2024, Python 3.14 + uv, Node 24,
Zig 0.16, NixOS 26.05), postgres 18 / mongo 8, lockfiles built from, non-root
runtimes, .dockerignore, per-project LICENSE, READMEs with the git.devai.io clone
line, checkout@v7 CI. Security fixes in the legacy Rust APIs (any-password login,
self-assigned admin, hard-coded JWT secret), JWT alg/exp/sub enforcement across the
blog series, safe markdown links in the frontends, and many smaller bugs — every
project was built, run and exercised end to end.

Adds scripts/publish.sh + a CI publish job that splits every folder into its own
repo at git.devai.io/templates/<folder>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01128fhuZbgivaSJvtMf4s1G
2026-09-27 21:10:38 +02:00

63 lines
2.2 KiB
Markdown

# ip-lookup
Open the page and it tells you your public IP address, rough location,
internet provider and time zone — with a link to the spot on a map. No search
box: the API describes the very request you send it.
## Run
Get it: `git clone https://git.devai.io/templates/ip-lookup.git`
Double-click `index.html` — it opens in your browser and works, as long as
you're online (it asks the lookup service about you live). Nothing to install.
Or serve it like production:
```sh
docker compose up --build
```
Then open http://localhost:8080.
## How it works
Most APIs need you to say what you're asking about. This one doesn't:
`fetch("https://ipwho.is/")` sends no parameters, and the service looks at
where the request came from — your IP address — and answers with what it knows
about it. Whoever opens the page gets their own answer. It's free and needs no
key.
Two details worth copying:
- **`success: false` inside a 200.** When a lookup fails, this API still
answers HTTP 200 and puts `success: false` in the JSON. Checking `res.ok` is
not enough, so the code checks the field too.
- **Nested, optional fields.** `connection.isp` and `timezone.id` live one level
down; `d.connection?.isp || "Unknown"` keeps the page working if either is
missing.
The coordinates become an OpenStreetMap link, the Refresh button runs the same
fetch again, and "Loading…" and a friendly error cover the waits and failures.
Try it: show your `postal` code or `connection.org`, link to another map
service instead, or refresh automatically with `setInterval(load, 30000)`.
## Layout
```
index.html a status line, a hidden result card and the Refresh button
app.js load() and render()
styles.css the look; follows your system's light or dark mode
```
## Deploy
Push to your own GitHub repo and the shipped workflow
(`.github/workflows/ci.yml`) tests the compose stack, publishes the image to
GHCR, and — once you set the `DEPLOY_HOST` / `DEPLOY_USER` variables and
`DEPLOY_KEY` secret — deploys it to your server over ssh.
---
Part of [devai.io](https://devai.io) — the APIs & Data track: fetch real data
from the internet. Next up, a real backend:
[nasa-photo-proxy](https://git.devai.io/templates/nasa-photo-proxy).