emptygif
भाषा: मराठी

सर्व भाषा आणि फ्रेमवर्क

Dream OCaml

Dream साठी OCaml स्निपेट, जो /pixel.gif वरच्या रिक्वेस्टना empty GIF ने उत्तर देतो. GIF स्टार्टअपला एकदाच डिकोड होतो.

Dream OCaml

इन्स्टॉल
opam install dream base64
फाइल
pixel.ml
चालवा
dune exec ./pixel.exe
(* dune: (executable (name pixel) (libraries dream base64)) *)
let gif = Base64.decode_exn "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="

let () =
  Dream.run ~interface:"0.0.0.0" ~port:8080
  @@ Dream.logger
  @@ Dream.router
       [
         Dream.get "/pixel.gif" (fun _ ->
             Dream.respond
               ~headers:[ ("Content-Type", "image/gif"); ("Cache-Control", "no-store") ]
               gif);
       ]

फ्रेमवर्कच्या सध्याच्या डॉक्युमेंटेशनशी जुळवून तपासले.

तपासा

curl -sI http://localhost:8080/pixel.gif

अधिकृत साइट: Dream