问题
The question title says itself.
I find pyramid in python is quite easy to use.
In OCaml, I know Eliom, but guess it too heavy. And also in client side, I will use angular js and don't need to write browser page in OCaml.
Any suggestions?
回答1:
OWebl is a new project that I personally find very promising, and it looks like that it can suite your needs quite well. Other option, is to use cohttp directly or with opium
回答2:
Eliom doesn't have to be "heavy"; but I think their docs have a slight PR issue there …
Here's a minimal Eliom page that just serves up some HTML from a string when you visit the path /aaa/bbb (from https://ocsigen.org/tuto/manual/basicwebsite):
let f _ () =
Lwt.return "<html><head><title>A</title></head><body>B</body></html>"
let main_service =
Eliom_registration.Html_text.register_service
~path:["aaa"; "bbb"]
~get_params:Eliom_parameter.any
f
You'll also need a basic config for the server:
<ocsigen>
<server>
<port>8080</port>
<charset>utf-8</charset>
<extension findlib-package="ocsigenserver.ext.staticmod"/>
<extension findlib-package="ocsigenserver.ext.ocsipersist-dbm"/>
<extension findlib-package="eliom.server"/>
<host hostfilter="*">
<static dir="static" />
<eliommodule module="_build/foo.cmo" />
<eliom/>
</host>
</server>
</ocsigen>
Compile, run the server and try the page:
ocamlbuild -pkg eliom.server foo.cmo
ocsigenserver -v -c foo.conf
Wait for it to say ocsigenserver: main: Ocsigen has been launched (initialisations ok), then open http://localhost:8080/aaa/bbb.
Used that way, it doesn't feel very heavy-weight to me, and you can easily use the minimal parts that you need. That said, without knowing more about what you actually need, it's hard to say whether Eliom is the best choice :-)
来源:https://stackoverflow.com/questions/30156177/is-there-a-good-ocaml-lib-for-creating-a-web-service-like-pyramid-in-python