Skip to content

ncitron/oframl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oframl

Oframl is a simple framework for building Farcaster Frames in OCaml.

Usage

open Oframl

let image_handler (data : string) =
  let str = if String.equal data "initial" then
    "Click to fetch FID"
  else
    [%string "FID: %{data}"]
  in
  [%string
    {|<svg width='191' height='100' xmlns='http://www.w3.org/2000/svg'>
        <rect width='100%' height='100%' fill='black'/>
        <text x='95.5' y='50' text-anchor='middle'
          dominant-baseline='middle'
          font-family='Arial' font-size='12' fill='white'>
          %{str}
        </text>
      </svg>|}]
;;

let frame_handler (): frame = 
  { title = "FID Check"
  ; image_extra_data = "initial"
  ; post_extra_data = ""
  ; buttons = [ { content = "Check FID" } ]
  }
;;

let post_handler (act : action) (_data : string) : frame =
  { title = "FID Check"
  ; image_extra_data = string_of_int act.fid
  ; post_extra_data = ""
  ; buttons = []
  }
;;

let base_url = "https://df78-72-69-118-50.ngrok-free.app" in
let start = Server.start base_url frame_handler post_handler image_handler in
Lwt_main.run start

Examples

To view more examples see examples

About

A framework for building Farcaster Frames in OCaml

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages