Advertisement
Guest User

Untitled

a guest
Aug 27th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.73 KB | None | 0 0
  1. let%server get_status () =
  2.   let open Uri in
  3.   let open Cohttp in
  4.   let open Cohttp_lwt_unix in
  5.   let open Lwt in
  6.  
  7.   let uri = "localhost/api/_status" in
  8.   let uri = Uri.of_string uri in
  9.   let uri = Uri.with_port uri (Some 59231) in
  10.   Client.get uri >|= fun (resp, body) -> resp |> Response.status |> Code.code_of_status
  11.  
  12. let%client get_status = ~%(Eliom_client.server_function [%derive.json: unit] get_status)
  13.  
  14. let a_button =
  15.   let b = Html.D.(button ~a:[a_class ["btn"]] [txt ""]) in
  16.  
  17.   ignore [%client
  18.     ((Lwt.async @@ fun () ->
  19.       let%lwt status_value = get_status () in
  20.       let b = Html.D.(th ~a:[a_class ["trading_column_header"]] [txt @@ string_of_int status_value]) in
  21.       Lwt.return_unit
  22.      ))];
  23.   b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement