Skip to content

Instantly share code, notes, and snippets.

@turbinenreiter
Created May 21, 2018 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turbinenreiter/309fa8750489c0fe3205d16e0f1a3f5e to your computer and use it in GitHub Desktop.
Save turbinenreiter/309fa8750489c0fe3205d16e0f1a3f5e to your computer and use it in GitHub Desktop.
#lang racket
(require markdown)
(require web-server/servlet)
(provide/contract (start (request? . -> . response?)))
(define (article-fnames path-to-articles)
(directory-list (string->path path-to-articles)))
(define (article-paths path-to-articles article-fnames)
(map (lambda (fname)
(build-path path-to-articles fname))
article-fnames))
(define (article-paths->xeprs article-paths)
(map parse-markdown article-paths))
(define fnames
(article-fnames "articles"))
(define articles
(article-paths->xeprs (article-paths "articles" fnames)))
;(define html
; (map (lambda (article)
; (map display-xexpr article))
; articles))
(define (start request)
(response/xexpr
`(html (head (title ,(path->string (first fnames))))
(body ,(first articles)))))
(require web-server/servlet-env)
(serve/servlet start
#:launch-browser? #t
#:quit? #f
#:listen-ip #f
#:port 8000
#:servlet-path
"/servlets/gantty.rkt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment