💾 Archived View for rwv.io › 2020-11-13.gmi captured on 2023-06-16 at 16:09:56. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Just spend an hour playing with racket (my first) to see if I can get a gemini server up and running. I can! It's awesome!
This is all it takes:
#lang racket (require racket/string) (require racket/port) (require net/url-string) (require openssl) (define root-path "root") (define (url-path->string p) (string-join (map path/param-path p) "/")) (define listener (let ((listener (ssl-listen 1965))) (ssl-load-certificate-chain! listener "localhost.cert.pem") (ssl-load-private-key! listener "localhost.key.pem" #f) listener)) (let loop () (let-values ([(in out) (ssl-accept listener)]) (let* ((url (string->url (string-trim (read-line in)))) (path (url-path->string (url-path url)))) (ssl-abandon-port in) (display "20 text/gemini\r\n" out) (let ((in (open-input-file (build-path root-path path) ))) (copy-port in out) (close-input-port in))) (ssl-abandon-port out)) (loop))
It only responds with "20", expects everything to be gemini text and crashes when the requested file does not exists. Not yet ready for "production" but that's plenty for a language I never used. Initial commit, done.
Cheers,
R.
--
📅 2020-11-13
🏷 gemini, racket, programming
📧 hello@rwv.io
CC BY-NC-SA 4.0