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
1
vote
1 answer

Convert BSON to JSON and send as API response Haskell

I'm working on my first Haskell web app, and am having trouble converting a BSON document into JSON and then sending it as an API response. I'm currently using the AesonBson package to convert my BSON to an Aeson Object, but can't figure out how to…
tydotg
  • 631
  • 4
  • 11
1
vote
1 answer

Match nested subdirectories with a Scotty RoutePattern

I'm serving some static files with my Scotty webserver. They can also be located in subdirectories. My current approach looks like this: get "/:fileName" $ do fileName <- param "fileName" file $ pathToStaticFiles fileName get…
Tobias Hermann
  • 9,936
  • 6
  • 61
  • 134
1
vote
1 answer

How to open a separate socket connection in Scotty or Yesod?

I am building an application that has to connect to an IRC network (open a socket) and also host a web app. Some data should be shared between an IRC part and Http part. What's the best way to achieve that kind of concurrency in Haskell? Should…
egdmitry
  • 2,071
  • 15
  • 18
1
vote
1 answer

Scotty and POST params

I'm having an issue with the Scotty web server right now - rescue isn't working for unfound parameters - I'm still getting a 404 with the following code: post "/newsletter/create" ( do (param "subscriber[email]") `rescue` (\msg -> text msg) …
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
1
vote
1 answer

Scotty Parameters to feed in Sqlite3

I'm trying to create a web site that will get information via URL routes and then pass this information into a HDBC SQLITE3 database. I have figured out how to get the information via parameters using Scotty as well as how to create a database…
Sleep Deprived Bulbasaur
  • 2,368
  • 4
  • 21
  • 33
1
vote
0 answers

Scotty, WAI: Capturing request body

I don't seem to be able to capture request body any more. Everything started here when I hit the problem after an update. I was trying to investigate it and got to a point where I cant get the request body niether with scotty's body function nor…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
1
vote
0 answers

Haskell Scotty and Angularjs: jsonData function stopped parsing json data sent with $http.post()

I have a Haskell/Scotty app with Angularjs as frontend. It worked flawlessly with regards to JSON parsing. Then it suddenly stopped for no reason. It happend after some Scotty and its dependencies version bump. There is not much error feed back from…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
1
vote
2 answers

How do i limit the size of a file upload in scotty?

I'm currently looking into Scotty for web development, and so far it looks pretty good. I'm worried though, that there seems to be no way to discard a file upload (or better yet an arbitrary POST body) where the file size is above a certain limit…
tauli
  • 1,420
  • 8
  • 13
1
vote
1 answer

Haskell: Testing connection availability N times with a delay (scotty to mongodb)

I have a stupid problem with scotty web app and mongodb service starting in the right order. I use systemd to start mongodb first and then the scotty web app. It does not work for some reason. The app errors out with connect: does not exist…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
0
votes
0 answers

ERR_EMPTY_RESPONSE when trying to access Scotty Application which runs in WSL2

I am building a web application using Scotty and have installed GHC and Cabal using GHCup inside of WSL2 (Windows Subsystem for Linux 2). The application worked when I ran it natively on Windows. I am running the application on port 3000 and I am…
0
votes
1 answer

Scotty and persistence - type error when using insert function

I've got the following application: {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE…
Henry
  • 3,472
  • 2
  • 12
  • 36
0
votes
1 answer

Use Redis.Message from outside of the pubSub callback

In the documentation for Hedis, an example of using the pubSub function is given: pubSub :: PubSub -> (Message -> IO PubSub) -> Redis () pubSub (subscribe ["chat"]) $ \msg -> do putStrLn $ "Message from " ++ show (msgChannel msg) return $…
Jivan
  • 21,522
  • 15
  • 80
  • 131
0
votes
1 answer

Is there any way to catch all exceptions in scotty without wrapping all of my code in Exception Catching

I would like for my default handler to be able to catch all of the exceptions that my App throws but in order for this to happen I need to manually call raise after manually adding some exception catching around my IO code. below is an example…
emg184
  • 850
  • 8
  • 19
0
votes
1 answer

How to use Scotty's ActionT monad like a Maybe monad, with an early http response returned for errors?

I would like to be able to return custom error pages and statuses to the user, and end computation in the ActionT monad when such an error occurs. My understanding is that this is a bit like a Maybe monad, where computation ends when the first…
bbarker
  • 11,636
  • 9
  • 38
  • 62
0
votes
1 answer

How to convert Scotty parameter as String

I am new to Haskell and testing some concepts with Scotty web library. However, I can't get a simple hello world page working. I am stuck at converting the parameter as String and apply to another function. Here is the high-level code that is not…
Gavin
  • 4,458
  • 3
  • 24
  • 37