scotty: Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp

[ bsd3, library, web ] [ Propose Tags ]

A Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp.

{-# LANGUAGE OverloadedStrings #-}

import Web.Scotty

import Data.Monoid (mconcat)

main = scotty 3000 $ do
  get "/:word" $ do
    beam <- param "word"
    html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]

Scotty is the cheap and cheerful way to write RESTful, declarative web applications.

  • A page is as simple as defining the verb, url pattern, and Text content.

  • It is template-language agnostic. Anything that returns a Text value will do.

  • Conforms to WAI Application interface.

  • Uses very fast Warp webserver by default.

This design has been done in Haskell at least once before (to my knowledge) by the miku framework. My issue with miku is that it uses the Hack2 interface instead of WAI (they are analogous, but the latter seems to have more traction), and that it is written using a custom prelude called Air (which appears to be an attempt to turn Haskell into Ruby syntactically). I wanted something that depends on relatively few other packages, with an API that fits on one page.

As for the name: Sinatra + Warp = Scotty.

WAI
http://hackage.haskell.org/package/wai
Warp
http://hackage.haskell.org/package/warp

[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.5.0, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.10.2, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.11.6, 0.12, 0.12.1, 0.20, 0.20.1, 0.21, 0.22 (info)
Dependencies aeson (==0.5), base (>=4.3.1 && <5), blaze-builder (==0.3), bytestring (==0.9.1), case-insensitive (==0.4), data-default (==0.3), enumerator (==0.4.16), http-types (==0.6.8), mtl (==2.0.1), text (==0.11.1), wai (==0.4.3), warp (==0.4.6) [details]
License BSD-3-Clause
Copyright (c) 2012 Andrew Farmer
Author Andrew Farmer <anfarmer@ku.edu>
Maintainer Andrew Farmer <anfarmer@ku.edu>
Revised Revision 1 made by AndrewFarmer at 2015-01-06T19:24:55Z
Category Web
Home page https://github.com/xich/scotty
Bug tracker https://github.com/xich/scotty/issues
Source repo head: git clone git://github.com/xich/scotty.git
Uploaded by AndrewFarmer at 2012-01-05T20:43:30Z
Distributions Arch:0.21, Debian:0.11.6, Fedora:0.12.1, LTSHaskell:0.20.1, NixOS:0.20.1, Stackage:0.22
Reverse Dependencies 63 direct, 42 indirect [details]
Downloads 61344 total (332 in the last 30 days)
Rating 2.5 (votes: 5) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for scotty-0.0.1

[back to package description]
Scotty
=====

A Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp.

  {-# LANGUAGE OverloadedStrings #-}
  import Web.Scotty

  import Data.Monoid (mconcat)

  main = scotty 3000 $ do
    get "/:word" $ do
      beam <- param "word"
      html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]

Scotty is the cheap and cheerful way to write RESTful, declarative web applications.

  * A page is as simple as defining the verb, url pattern, and Text content.
  * It is template-language agnostic. Anything that returns a Text value will do.
  * Conforms to WAI Application interface.
  * Uses very fast Warp webserver by default.

See examples/basic.hs to see Scotty in action.

    > runghc examples/basic.hs
    Setting phasers to stun... (ctrl-c to quit)
    (visit localhost:3000/somepath)

This design has been done in Haskell at least once before (to my knowledge) by
the miku framework. My issue with miku is that it uses the Hack2 interface
instead of WAI (they are analogous, but the latter seems to have more traction),
and that it is written using a custom prelude called Air (which appears to be an
attempt to turn Haskell into Ruby syntactically). I wanted something that
depends on relatively few other packages, with an API that fits on one page.

As for the name: Sinatra + Warp = Scotty.

Copyright (c) 2012 Andrew Farmer