Serving static contents in Snap
A website consists of two types of contents, static contents and dynamic contents. The static contents are the HTML files, images, a folders containing these files. These contents do not change per request. The dynamic contents depend upon route, parameters, and request type. The Snap Framework allows us to serve static contents seamlessly with the dynamic contents. In this recipe, we will look at how we can serve static contents with the Snap Framework.
How to do it...
- Create a new project,
static-contents-in-snap
, with thesimple
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 theexecutable
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 ...