💾 Archived View for gemini.marmaladefoo.com › blog › 5-Jun-2020_first_CGI.gmi captured on 2022-03-01 at 15:17:51. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Testing CGI with Gemini

Developing server side CGI applications for Gemini is similar to the web. You need a CGI compatible server and then to write a script using your preferred language.

Hello CGI world

The first CGI application here is a simple Hello world.

Hello CGI world

Development notes

For those interested, I'm using Rebol as my scripting language, and Molly Brown server

Rebol

Solderpunk's Molly Brown repo

Script overview

The script starts as follows.

#!/usr/local/bin/rebol -cs

REBOL [
    title: {a simple Gemini CGI script in REBOL}
    date: 4-Jun-2020
]

;---Gemini meta response 20 OK - start sending content to the client
;---terminate header with CRLF
prin "20 text/gemini; charset=utf-8"        
prin crlf      

;---load a simple CGI params decoding library to get the unescaped data
do %gemini-utils.r       
query:   get-query-string


Once those preliminaries are out of the way, we can start outputting to the client, based on however we want to handle the passed parameters.

;---now just printing the output and it is sent to the client.
print {# Simple CGI script for Gemini in REBOL}

;--- say hello to the user as a gemtext heading 2
print rejoin [newline {## Hello, [} (title-case name) {]} ]


Home