blob: d7dc1fabc3a3f5d1292f4adaaacde31bc779b1fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
;;; Copyright © 2019 - 2022 Jakob L. Kreuze <zerodaysfordays@sdf.org>
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see
;;; <http://www.gnu.org/licenses/>.
(define challenges (make-hash-table))
(define conn (connect-to-postgres-paramstring "dbname=jakob_comments"))
(define (get-comments request body)
(values '((content-type . (application/json)))
(scm->json-string
'((title . "whoa buddy")
(author . "Jakob Kreuze")
(date . "2022-03-27")
(text . "bad take, bad take!")))))
(define (put-comment request body)
(display (decode-form body))
(newline)
(values '((content-type . (text/plain))) "Hello hacker!"))
(define (make-challenge request body)
(let-values (((uuid value image) (new-captcha)))
(hash-set! challenges uuid value)
(hash-for-each (lambda (x y) (display x) (newline)) challenges)
(values `((content-type . (application/base64))
(access-control-allow-origin . "*")
(x-captcha-id . ,uuid))
(base64-encode image))))
|