- Create a new project, static-contents-in-snap, with the simple stack template:
stack --resolver lts-9.1 new static-contents-in-snap simple
- 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
- 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. ...