@@ 29,12 29,24 @@
(define (candidates req)
(response/json cands))
+(define votes '())
+
+(define (submit-vote bstr)
+ (let foo ([i 0])
+ (if (> (bytes-ref bstr i) 0)
+ (let ([s (bytes->string/utf-8 (subbytes bstr i))])
+ (set! votes (cons (string-split s ":") votes))
+ (println votes))
+ (foo (add1 i)))))
+
(define (vote req)
(let* ([data (request-post-data/raw req)]
[m (bytes->integer (subbytes data 0 (/ keylen 8)) #f)]
[s (bytes->integer (subbytes data (/ keylen 8) (* 2 (/ keylen 8))) #f)])
(if (equal? m (modular-expt s e n))
- (response/text "vote submitted")
+ (begin
+ (submit-vote (subbytes data 0 (/ keylen 8)))
+ (response/text "vote submitted"))
(response/text "invalid signature"))))
(define (sign req)
@@ 56,6 68,7 @@
[("key") key]
[else candidates]))
+(displayln "starting servlet...")
(serve/servlet dispatcher
#:port 5598
#:command-line? #t