> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mergent.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Cohttp + Lwt

> Learn how to create your first task using OCaml and Cohttp + Lwt

<Snippet file="quickstart/1_define_task.mdx" />

```ocaml server.ml
open Lwt.Infix
open Cohttp
open Cohttp_lwt_unix

let perform_task () =
  (* This is where you'll perform your task.
     For now, we'll just log it. *)
  Lwt_io.printf "Performing task: %s\n"

let server =
  let callback _conn req _body =
    let uri = req |> Request.uri |> Uri.to_string in
    match Uri.path (Request.uri req) with
    | "/api/tasks" -> begin
        perform_task () >>= fun () ->
        Server.respond_string ~status:`OK ~body:"" ()
      end
    | _ ->
        Server.respond_string ~status:`Not_found ~body:"Route not found" ()
  in
  Server.create ~mode:(`TCP (`Port 3000)) (Server.make ~callback ())
```

<Snippet file="callout_params_api_reference.mdx" />

<Snippet file="quickstart/2_get_handler_url.mdx" />

<Snippet file="quickstart/3_create_first_task.mdx" />

<Snippet file="quickstart/4_next_steps.mdx" />

<AccordionGroup>
  <Snippet file="quickstart/accordion_use_cron_dashboard.mdx" />

  <Snippet file="quickstart/accordion_create_task_ocaml.mdx" />
</AccordionGroup>

<Snippet file="learn_more.mdx" />
