#!/usr/bin/env fun /* * This file is part of the Fun programming language. * https://fun-lang.xyz/ * * Copyright 2026 Johannes Findeisen * Licensed under the terms of the Apache-2.0 license. * https://opensource.org/license/apache-2-0 * * Added: 2026-03-25 */ #include cgi = CGI() name = cgi.param("name") if (len(name) == 0) name = "World" ua = cgi.cookie("ua") if (len(ua) == 0) // Set a demo cookie via header() cgi.header("Set-Cookie", "ua=FunClient; Path=/; HttpOnly") cgi.content_type("text/html; charset=utf-8") html = "" html = html + "Fun CGI" html = html + "

Hello, " + cgi.escape_html(name) + "!

" html = html + "

REQUEST_METHOD: " + cgi.escape_html(cgi.env["REQUEST_METHOD"]) + "

" html = html + "

QUERY_STRING: " + cgi.escape_html(cgi.env["QUERY_STRING"]) + "

" html = html + "

User-Agent cookie: " + cgi.escape_html(ua) + "

" // Render parsed CGI params as key => value(s) pmap = cgi.params() html = html + "

Params

" html = html + "" // Send CGI headers + body cgi.send(html) /* Expected output (GET /hello.fun?name=Fun with no ua cookie): Status: 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: ua=FunClient; Path=/; HttpOnly Fun CGI

Hello, Fun!

REQUEST_METHOD: GET

QUERY_STRING: name=Fun

User-Agent cookie:

Params

*/