-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgravatar.rkt
More file actions
33 lines (24 loc) · 816 Bytes
/
Copy pathgravatar.rkt
File metadata and controls
33 lines (24 loc) · 816 Bytes
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
#lang racket
#|
gravatar.rkt
GravatarDemo-Racket
Created by Bracken Spencer.
Copyright (c) 2020-2021 Bracken Spencer. All rights reserved.
|#
(require file/md5
json
net/url
racket/draw
"./fetch-a-url.rkt")
(include "./fetch-a-url.rkt")
(provide md5-email image-url profile-url)
(define (md5-email email)
(format "~a" (md5 email)))
(define (image-url email size)
(string-append "https://www.gravatar.com/avatar/" (md5-email email) "?s=" (number->string size) "&r=x"))
(define (profile-url email)
(string-append "https://www.gravatar.com/" (md5-email email) ".json"))
(define (profile-request email)
(bytes->jsexpr (http-request (profile-url email))))
(define (image-request email [size 100])
(read-bitmap (get-pure-port (string->url (image-url email size)))))