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
2
votes
0 answers

Scotty and the Reader Monad

I'm trying to bring the Reader monad in my Scotty application, as a means of having a unified root path for URL expansion internally. I can't seem to wrap my head around how Scotty handles monad transformation - normally, I would just see something…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
1
vote
1 answer

Haskell: Keeping track and modifying state with Scotty HTTP API

Can I modify my state using IO via the Scotty API? Currently, I have a state transformer inside IO monad to modify state with user input. But I want to achieve this via the Scotty API. This is my state transformer types I currently have that I use…
maxharrison
  • 59
  • 1
  • 5
1
vote
1 answer

Serve static css file using WAI middleware and Scotty

I have the following Main.hs {-# LANGUAGE OverloadedStrings #-} module Main where import Web.Scotty import Network.Wai.Middleware.RequestLogger import Network.Wai.Middleware.Static import Text.Blaze.Html.Renderer.Text (renderHtml) import qualified…
Henry
  • 3,472
  • 2
  • 12
  • 36
1
vote
1 answer

How to test Scotty endpoints

With the following Scotty endpoint: myendpoint :: Text -> ScottyM () myendpoint info = post "/foo/bar/:var" $ do var :: Text <- param "var" query :: Query <- jsonData result <- liftIO $ retrieveResult info var query …
Jivan
  • 21,522
  • 15
  • 80
  • 131
1
vote
1 answer

Haskell Scotty ‘Home.main’ is applied to too few arguments

I need to start up my very simple webapp with Haskell's Scotty and I just can't seem to get the IO () ReaderT stuff workinng. I am basing this off of another example I found online, and am pretty new to Monads and Haskell overall. My IDE is throwing…
1
vote
1 answer

How to make `co-log`'s `withLog` work with `Scotty`?

I already asked on Reddit but wanted to ask a wider circle for help. Here's a repository with code that you can run for a minimal test case: https://github.com/cideM/co_log_issue If you run stack build you'll get: • Could not deduce (HasLog …
Vey
  • 435
  • 5
  • 15
1
vote
1 answer

Why a pattern-matching failure is not catching by the exception handler?

Why pattern-matching failure is not catching by my exception handler excToStr in this case? I have a handler of an incoming POST request as under the control of the Scotty Web framework: ... import qualified Web.Scotty as W ... W.post…
RandomB
  • 3,367
  • 19
  • 30
1
vote
0 answers

With Scotty, how can I combine ScottyM with a custom monad with ScottyT

data MyAppR = MyAppR { dbPool :: Pool Connection } type NewApp = ReaderT (MyAppR) IO type AppActionNew a = ActionT L.Text NewApp a type AppServerNew a = ScottyT L.Text NewApp a type App = IO type AppServer a = ScottyT L.Text…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1
vote
1 answer

Haskell scotty Action to IO

I am back again trying to learn Haskell and, oh boy it is difficult! I am a trying to do a simple mongoDB insertion inside a Scotty endpoint. Problem is the type return by the insert function is not accepted in the Scotty do statement. The program…
1
vote
1 answer

How to run IO inside ScottyM

I'm using Scotty to write a small web apps. I need to run IO inside the ScottyM type. There are several difficulties: First I can't automatically derive type synonyms from MonadIO in order to run liftIO: type ScottyM = ScottyT Text IO Second, I…
daydaynatation
  • 550
  • 2
  • 8
1
vote
0 answers

How to deal with HTML select using in a scotty and Text.Blaze.Html5

I am using scotty and Text.Blaze.Html5 Text.Digestive Text.Digestive.Blaze.Html5  What I want to achieve is a list of options as shown below. Option select example image I have a Option sum type and will like to restrict the user to those…
tebogo
  • 11
  • 3
1
vote
2 answers

Most elegant way to start several scotty servers in the same application?

Is there a standard way to start two scotty servers in the same application? In a toy project I'm trying: main :: IO () main = do scotty 3000 $ do get "/" $ do text "hello" scotty 4000 $ do post "/" $ do text "world" The…
Mike
  • 716
  • 4
  • 10
1
vote
1 answer

Execute shell script from a POST request with scotty

I'm using scotty and I'm getting the same type error any way I try to execute a shell script from a POST request. main = scotty 3000 $ do post "MyPage/ScriptTime/run" $ do aparameter <- param "aparameter" bparameter <- param…
mttpgn
  • 327
  • 6
  • 17
1
vote
1 answer

wai-logger FileLogSpec as Scotty Middleware reporting openFile: resource busy (file is locked)

I am using Scotty for a backend application in Haskell and I am interested in logging all requests to a file. The existing wai-middleware requestlogger is not enough as I would like the properties of FileLogSpec, since I like have multiple but short…
Casper Thule Hansen
  • 1,510
  • 2
  • 19
  • 36
1
vote
1 answer

Save state in memory [Haskell Server]

I am attempting to create a server that returns two different values from a route depending if a user has visited it before. I have the following code: {-# LANGUAGE OverloadedStrings #-} module Main where import Web.Scotty main = do putStrLn…
timothyylim
  • 1,399
  • 2
  • 14
  • 32