Questions tagged [scotty]

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)

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

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.

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

104 questions
3
votes
2 answers

MonadReader instance for Scotty's ActionT

I have the type ActionT TL.Text (ReaderT T.Text IO) I'm trying to make a MonadReader instance for this so that I do not have to lift ask, but always get (All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type…
Ivan Meredith
  • 2,222
  • 14
  • 13
2
votes
2 answers

How to insert array using postgresql simple (Haskell)?

I am working on a Haskell API using Scotty and PostgreSQL-simple. I cannot figure out how to do an insert of a column containing an Array of Text. So far my queries have worked, but something about this one does not seem to compile well. This is…
2
votes
1 answer

How to run an action after response has been fully sent in Scotty / WAI

Upon a GET request, my Scotty webapp will run some computation and store its result in a temporary file, which it sends as the response using file. Now I would like to run some cleanup (i.e. delete the temporary file) after the file has been sent.…
2
votes
0 answers

Trouble working with `requestBody` (or `getRequestBodyChunk`)

Dependency versions Wai: 3.2.2.1 Synopsis The working of getRequestBodyChunk (https://hackage.haskell.org/package/wai-3.2.2.1/docs/Network-Wai.html#v:getRequestBodyChunk) is quite unclear to me. I understand that it reads the next chunk of bytes…
Ashesh
  • 2,978
  • 4
  • 27
  • 47
2
votes
2 answers

How should I handle a long-running HTTP request, using Scotty (Haskell)?

I'm making a simple web app that looks for color words in a text, and plots statistics about them. You can test it at colors.jonreeve.com if it's not too busy. I'm using the Scotty web framework to handle the web stuff. It works OK for short texts,…
Jonathan
  • 10,571
  • 13
  • 67
  • 103
2
votes
1 answer

How to use a monad stack with scotty and selda?

I've been trying to get a web server running with scotty that can communicate with my db, using selda. I thought using a monad transformer stack would be the way to accomplish something like that. I've been trying to work it out, but I've run into a…
Marcus Buffett
  • 1,289
  • 1
  • 14
  • 32
2
votes
1 answer

Using ReaderT transformer in ScottyT (vs ActionT)

I'm trying to thread configuration through my Scotty based application using ReaderT monad transformer approach, and having trouble doing so. I have to use configuration both when defining routes (as some of them depend on the config) and when…
SkyWriter
  • 1,454
  • 10
  • 17
2
votes
1 answer

Multiple before functions in HSpec?

I have an in-memory repository that I can create by calling this function: newEmptyRepository :: IO InMemoryGameRepository where InMemoryGameRepository is defined like this: type State = (HashMap GameId Game) type IORefState = IORef State newtype…
Johan
  • 37,479
  • 32
  • 149
  • 237
2
votes
1 answer

Working with Scotty and Sqlite and having some trouble with the Monads

Hi I a pretty new to Haskell and I have been working on a small web application with Scotty and Sqlite. I am having trouble performing Sqlite operations inside the Scotty Actions. I kind of understanding the two libraries when used in…
jo_wil
  • 369
  • 3
  • 11
2
votes
1 answer

Forking new Threads in Scotty Server

I am prototyping a Web server in Scotty with two APIs: /add/:id starts an asyc task with the given Id. /cancel/:id kills the task for the given Id. Basically clients start async tasks by providing some Ids and can also kill their current tasks by…
homam
  • 1,945
  • 1
  • 19
  • 26
2
votes
3 answers

Haskell database connections

Please look at this scotty app (it's taken directly from this old answer from 2014): import Web.Scotty import Database.MongoDB import qualified Data.Text.Lazy as T import Control.Monad.IO.Class runQuery :: Pipe -> Query -> IO [Document] runQuery…
haskellHQ
  • 1,027
  • 6
  • 15
2
votes
0 answers

Haskell REST Service with Scotty: Convert JSON back to to Data

I built a REST Service with Haskell and Scotty and have the following code: {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveGeneric #-} module Main where import Data.Monoid ((<>)) import Data.Aeson (FromJSON, ToJSON) import…
ManfredP
  • 1,037
  • 1
  • 12
  • 27
2
votes
1 answer

Why does this work in GHCi but not Scotty?

I am trying to make a webpage that will list the contents of a given directory, but I am running into a strange problem: The code produces the desired output when I run it line by line in GHCi, but when it is executed in the running Scotty instance,…
asg0451
  • 493
  • 4
  • 13
2
votes
1 answer

Dynamically importing modules in Haskell

I'm building a Scotty-based application and I'm trying to import and add a list of dynamic middlewares contained in a directory. I don't want to hard-code my list of middleware - but as of now I'm using a Index.hs which expose all the directory…
framp
  • 813
  • 11
  • 22
2
votes
1 answer

Haskell Scotty Webserver send a text response

I get a GET request and want to send a text message as a response to it.I have the following code but am getting the following error {-# LANGUAGE OverloadedStrings #-} import Web.Scotty import Network.Wai.Middleware.RequestLogger import Data.Monoid…
custosat
  • 99
  • 8