open Tyxml open Stack_picker.Srv (* let () = Eio_main.run @@ fun env -> *) (* let url = "sqlite3://stack.db" |> Uri.of_string in *) (* Caqti_eio_unix.with_connection ~stdenv:(env :> Caqti_eio.stdenv) url (Stack_picker.Db.test env#stdout) *) (* |> Caqti_eio.or_fail *) let () = Logs.set_reporter (Logs_fmt.reporter ()) and () = Logs.Src.set_level Cohttp_eio.src (Some Debug) let () = let port = ref 8080 in Arg.parse [ ("-p", Arg.Set_int port, " Listening port number(8080 by default)") ] ignore "An HTTP/1.1 server"; Eio_main.run @@ fun env -> Eio.Switch.run @@ fun sw -> run ~env ~sw ~port:!port [ get "/ping" (fun _req -> let num = 1 in let resp = Printf.sprintf "Hello this is the num: %d" num |> Eio.Flow.string_source in Stack_picker.Srv.respond ~body:resp ()); get "/" (fun _ -> let%html html_doc = {|
Hello from ocaml!
|} in Stack_picker.Srv.respondHtmlDoc ~body:html_doc ()); get "/shop" (fun _ -> let%html doc = {|