💾 Archived View for gemini.marmaladefoo.com › blog › 5-Jun-2020_first_CGI.gmi captured on 2022-07-16 at 13:48:52. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
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 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) {]} ]