Scotty Web Framework

repository·master·Indexed 23 days ago

https://github.com/scotty-web/scotty

A lightweight, declarative Haskell web framework inspired by Ruby's Sinatra. Built on the WAI interface and Warp webserver, Scotty allows for the quick development of RESTful web applications by specifying HTTP verbs and URL patterns.

Tokens
417
Snippets
3
Records
3
Agent score
33%

What's inside Scotty

  1. Quickstart with Scotty

    master

    Scotty is a lightweight, Sinatra-inspired Haskell web framework built on WAI and Warp. You can define a web application by specifying HTTP verbs (like get), URL patterns, and returning text content. It is template-agnostic; any value that can be converted to Text can be used to render a page.

    To run a basic Scotty application, use runghc on a source file or use stack exec if you have the package installed via Stack.

    {-# LANGUAGE OverloadedStrings #-}
    import Web.Scotty
    
    main = scotty 3000 $
        get "/:word" $ do
            beam <- pathParam "word"
            html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
  2. Troubleshoot regex-posix compilation on Windows

    master

    If you encounter compilation failures for regex-posix on Windows, apply the following configuration based on your build tool:

    For Stack users: Add these parameters to your stack.yaml:

    extra-deps:
    - regex-posix-clib-2.7
    flags:
      regex-posix:
        _regex-posix-clib: true

    For Cabal users: Update the constraints section of your cabal.project.local:

    constraints: regex-posix +_regex-posix-clib
    constraints:
      regex-posix +_regex-posix-clib
  3. Run Scotty examples

    master

    You can run the provided basic example to see Scotty in action using runghc or stack.

    Using runghc:

    runghc examples/basic.hs

    Using stack:

    stack exec -- scotty-basic

    Once the server is running (defaulting to port 3000), you can test it with curl:

    curl localhost:3000
    runghc examples/basic.hs