💾 Archived View for gemini.marmaladefoo.com › blog › 5-Jun-2020_first_CGI.gmi captured on 2020-09-24 at 00:52:09. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
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.
The first CGI application here is a simple Hello world.
For those interested, I'm using Rebol as my scripting language, and Molly Brown server
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 load-webform function do %altwebform.r ;---get the query string from the server and unpack it into a block of passed parameters handle-get: funct [] [ data: any [( get-env "QUERY_STRING") ""] return load-webform data ] params: handle-get
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} <script continues...>