tclestial

A programmable Gemini server written in tcl.

Source Code

Create a simple file defining routes, or make a super complex system with multiple packages.

Currently supports

- Gemini Protocol

- Client Side certs with SHA1 stored in SQLite DB

Example Code

package require tclestial

proc handleRoutes {acc} {
    $acc log "info" "Received request for [$acc getPath]"

    switch -exact [$acc getPath] {
        "/" {
            $acc sendHeader "20" "text/gemini"
            $acc sendData "# Welcome to tclestial Gemini server!"
            $acc sendData ""
            $acc sendData "This is a simple Gemini server written in Tcl."
            $acc sendData ""
            $acc sendLink "/hello" "Hello"
            $acc sendLink "/link" "Links"
            $acc sendLink "/user" "About the user and cert"


        }
        "/user" {
            set user [$acc getUser]
            $acc sendHeader "20" "text/gemini"
            $acc sendData "# User information:"
            $acc sendData "- id: [dict get $user id]"
            $acc sendData "- user: [dict get $user username]"
            $acc sendData "- sha1: [dict get $user sha1]"
            $acc sendData ""
            $acc sendLink "/" "Back"

        }
        default {
            $acc sendHeader "51" "text/gemini"
            $acc sendData "Not Found"
        }
    }
}

set cfg {
    port 1965
    certFile "localhost-cert.pem"
    keyFile "localhost-key.pem"
}

tclestial::startup $cfg handleRoutes