package oframl

  1. Overview
  2. Docs
Farcaster Frames in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

0.0.1.tar.gz
md5=a38e5b6b0e2b52a1093ca027fd9c3e09
sha512=8338e3b762bec277f4532ae51a2420041398943e21d312afd0acdd2dd4a25c01e0e7ebd021dad7444f578eeac3e50482907e5a9aa0791717d718064d5e2feb19

Description

A framework for building Farcaster Frames in OCaml

Tags

topics Farcaster Frames

Published: 07 Feb 2024

README

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

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.