Arc Forumnew | comments | leaders | submitlogin
5 points by rcoder 6140 days ago | link | parent

For those who want a slightly less-complete webapp to use as a sample:

  (= fortune-bin-path* "/usr/games/fortune" page-title* "Read My Fortune")

  (def make-fortune-cookie ()
    (tostring (system fortune-bin-path*)))

  (defop fortune req
    (whitepage
      (tag h1 (link page-title* "fortune"))
      (br 2)
      (tag pre (pr (make-fortune-cookie)))
      (br 2)
      (tag small
        (link "[made with arc]" "http://arclanguage.org/"))))


1 point by albertcardona 6140 days ago | link

For illustration, would you mind explaining how to connect this code to a web server.

-----

2 points by rcoder 6140 days ago | link

You don't have to connect it. Copy the above into a file called 'fortune.arc' inside your Arc source code directory, then type the following from an Arc REPL:

  (load "fortune.arc")
  (asv)
The 'asv' function spawns the built-in web server, as shown in the blog example.

-----

1 point by albertcardona 6137 days ago | link

Sometimes the program fails with the error below, on clicking on the link. A blank webpage is shown. After F5 (refresh), all back to normal.

Looks to me, that the system call fails because 'fortune' returns -1.

  date: 1202019843: No such file or directory
  make-string: expects argument of type <non-negative exact integer>; given -1

  === context ===
  subseq
  memodate
  srvlog
  gs899
  handle-request-thread

-----