Here is one solution for this assignment:

import { serve } from 'https://deno.land/std/http/server.ts';
import { parse } from 'https://deno.land/std/flags/mod.ts';
const { args } = Deno;
const parsedArgs = parse(args);
const port = parsedArgs.port || 8000;

const server = serve({ port });
let requestsRespondedTo = 0;

console.log(`Listening on port ${port}`);

for await (const req of server) {
  if (req.method === 'GET') {
    req.respond({ body: JSON.stringify({ message: 'Hello there!', count: ++requestsRespondedTo }) });
  } else {
    req.respond({ body: 'ERROR: Only GET requests supported', status: 500 })
  }
}