O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create a new project, static-contents-in-snap, with the simple stack template:
        stack --resolver lts-9.1 new static-contents-in-snap simple
  1. Add a dependency on the following libraries in the build-depends subsection of the executable section:
   executable static-contents-in-snap
     hs-source-dirs:      src
     main-is:             Main.hs
     default-language:    Haskell2010
     build-depends:       base >= 4.7 && < 5
                       , snap-server
                       , snap-core
                       , snap
                       , lens
                       , bytestring
                       , text
  1. Add a directory, static, in the project folder. Add index.html in this directory, as follows:
 <!DOCTYPE HTML5>
 <html>
   <body>
     <p> This file is served as a static content. You may add     links to subfolder as well. But the folder ".." and absolute path are not honoured while serving the directory. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required