<commit_before>## Installation

The exposed Snap API is on the same level of abstraction as Java Servlets. If
you understand servlets, most of the rest of the tutorial should be very
self-explanatory. Even if you don't, have no fear!  The following tutorial only
expects that you know a little bit of Haskell.

Before we dive into writing our first Snap web application, let's do a quick
overview of the parts of the Snap framework. Currently Snap is divided into
four components:


  - `snap-core` is the core of Snap. It includes type definitions and all code
  that is server-agnostic.

  - `snap-server` is an HTTP server library built on top of `snap-core`. It
  currently includes a backend using stock Haskell socket I/O and a backend
  which uses the [libev](http://software.schmorp.de/pkg/libev.html) O(1) event
  loop library.

  - `heist` is the HTML templating library. You do not need it to use Snap,
  but you are certainly welcome to.

  - `snap` is a library which contains the extension framework for organizing
  pieces of Snap sites.  It also contains a `snap` executable which generates
  a skeleton project to get you started.

To install Snap, simply use `cabal`.

~~~~~~ {.shell}
$ cabal install snap
~~~~~~

It's up to you whether or not you want to use the Heist templating library.
However, heist is a dependency for the snap project starter, and our example
below does use it.

## Hello, Snap!

To generate a skeleton Snap web application, the `snap` package installs an
executable `snap` into `$HOME/.cabal/bin`. We can use that to create our "Hello
Snap" application.

(Normally, snap builds an example using Heist and a custom extension to get your
project started.  Use `snap init -b` instead of `snap init` for a bare-bones
skeleton.)

~~~~~~ {.shell}
$ mkdir hello-snap
$ cd hello-snap
$ snap init
~~~~~~

We now have a skeleton Snap project with a `.cabal` file and a source
directory. Install and run it:
~~~~~~ {.shell}
$ cabal install
$ hello-snap -p 8000
Initializing Heist/Impl... done.
Initializing Timer/Timer... done.
Listening on http://0.0.0.0:8000/<commit_msg>Added draft of 0.4 release notes.<commit_after>## Installation

The exposed Snap API is on the same level of abstraction as Java Servlets. If
you understand servlets, most of the rest of the tutorial should be very
self-explanatory. Even if you don't, have no fear!  The following tutorial only
expects that you know a little bit of Haskell.

Before we dive into writing our first Snap web application, let's do a quick
overview of the parts of the Snap framework. Currently Snap is divided into
four components:


  - `snap-core` is the core of Snap. It includes type definitions and all code
  that is server-agnostic.

  - `snap-server` is an HTTP server library built on top of `snap-core`. It
  currently includes a backend using stock Haskell socket I/O and a backend
  which uses the [libev](http://software.schmorp.de/pkg/libev.html) O(1) event
  loop library.

  - `heist` is the HTML templating library. You do not need it to use Snap,
  but you are certainly welcome to.

  - `snap` is a library which contains the extension framework for organizing
  pieces of Snap sites.  It also contains a `snap` executable which generates
  a skeleton project to get you started.

To install Snap, simply use `cabal`.

~~~~~~ {.shell}
$ cabal install snap
~~~~~~

It's up to you whether or not you want to use the Heist templating library.
However, heist is a dependency for the snap project starter, and our example
below does use it.

## Hello, Snap!

To generate a skeleton Snap web application, the `snap` package installs an
executable `snap` into `$HOME/.cabal/bin`. We can use that to create our "Hello
Snap" application.

(Normally, snap builds an example using Heist and a custom extension to get your
project started.  Use `snap init -b` instead of `snap init` for a bare-bones
skeleton.)

~~~~~~ {.shell}
$ mkdir hello-snap
$ cd hello-snap
$ snap init
~~~~~~

We now have a skeleton Snap project with a `.cabal` file and a source
directory. Install and run it:

~~~~~~ {.shell}
$ cabal install
$ hello-snap -p 8000
Initializing Heist/Impl... done.
Initializing Timer/Timer... done.
Listening on http://0.0.0.0:8000/
{'fraction_non_alphanumeric': 0.08177735759867644, 'fraction_numerical': 0.006617820846135665, 'mean_word_length': 3.781920903954802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1676971', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1188, 'n_words': 638}