You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some typos in readme for OCaml static files example, but I was able to make it work like this:
let server_config: unitNaboris.ServerConfig.t =Naboris.ServerConfig.create ()|>Naboris.ServerConfig.setRequestHandler(funroutereqres ->
match ((Naboris.Route.meth route), (Naboris.Route.path route)) with| (Naboris.Method.GET, "static" :: static_path) ->
Naboris.Res.static (Sys.getcwd()^"/static") static_path req res
| (Naboris.Method.GET, "/" :: []) ->
Naboris.Res.static (Sys.getcwd()^"/static") ["/index.html"] req res
| (Naboris.Method.GET, "" :: []) ->
Naboris.Res.static (Sys.getcwd()^"/static") ["/index.html"] req res
|_ ->
res
|>Naboris.Res.status 404|>Naboris.Res.text req "Resource not found.";
)
let _ =Lwt_main.run beginNaboris.listenAndWaitForever 3000 server_config
end
By this index.html file from static folder is opened when gethttp://localhost:3000/ or http://localhost:3000.
Would be nice to have static folder by default or via parameter in ServerConfig for serving up static files. It can be useful for SPA.
The text was updated successfully, but these errors were encountered:
There are some typos in readme for OCaml static files example, but I was able to make it work like this:
By this index.html file from static folder is opened when get
http://localhost:3000/
orhttp://localhost:3000
.Would be nice to have
static
folder by default or via parameter inServerConfig
for serving up static files. It can be useful for SPA.The text was updated successfully, but these errors were encountered: