Exercises for Programmers AI

Working with External Services
Creating Your Own Time Service
Not implemented as a static page

This exercise is a meta-exercise: the thing you are asked to build is a JSON API server. A static Next.js page is a client — it can consume a service, but it cannot be one in the way the exercise intends.

How this would work

The server component would be a minimal HTTP server (for example, a few lines of Node.js using the built-in http module, or a single-file Express app) that listens on a port and responds to any GET request with a JSON body:

{ "currentTime": "2050-01-24 15:06:26" }

The response Content-Type header would be set to application/json. The timestamp would be generated fresh on each request using the server's system clock, formatted as YYYY-MM-DD HH:mm:ss in UTC.

The client component would be a separate program that sends a GET request to the server URL, parses the JSON response, and prints the time in a human-readable format:

The current time is 15:06:26 UTC January 24 2050.

Why it needs a backend

Next.js API routes could technically serve the JSON endpoint, but that would mean this application is the server — the exercise asks you to build and run two separate programs (server and client) to understand the client/server relationship. Collapsing them into one Next.js app defeats the purpose of the exercise.