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

Scotty Convert GET Parameter / Lazy.Text conversion

I try to pass a GET parameter into a function and concat a string from the result {-# LANGUAGE OverloadedStrings #-} module Main where import Data.Monoid ((<>)) import Web.Scotty f x = x <> x main = do scotty 3000 $ do get "/f/:x" $ do …
Nicolas Heimann
  • 2,561
  • 16
  • 27
1
vote
1 answer

How to upload a file to website with file contents in post body

How do I upload a file to my web server from a browser? The server is written in Haskell, using Scotty. Here is what I have tried: Server: {-# LANGUAGE OverloadedStrings #-} module Main where import qualified Data.ByteString.Lazy as BL import…
8n8
  • 1,233
  • 1
  • 8
  • 21
1
vote
1 answer

Blocking Threads in Haskell

I'm start coding async with Haskell, and for now I'm using forkIO which create a green thread(It's that correct? is a green thread?) and then I'm using a MVar to communicate from the new thread to the main thread once I finish and I have the value.…
paul
  • 12,873
  • 23
  • 91
  • 153
1
vote
1 answer

Add print in Scotty do block

I'm very new to Haskell so sorry in advance if the question is silly, but I was not able to find the solution in google. Let's say that I have this program using the Scotty web framework: responseUserByName :: ActionM () responseUserByName = do…
paul
  • 12,873
  • 23
  • 91
  • 153
1
vote
1 answer

How to get data from sqlite and response json using scotty?

I'm trying to build a simple blog using Haskell and the Framework Scotty. Using a Model.hs I have: data Post = Post { id :: Int , tipo :: String , titulo :: String , conteudo :: String } deriving (Show, Generic) I've already…
itepifanio
  • 572
  • 5
  • 16
1
vote
1 answer

Haskell scotty and persistence rest API

I'm new in Haskell. I woudl like to create simple crud rest api with scotty and persistence. I'm using sqlite with one table todo (title text, description text), I have some records in table. My point is to show all records on enpoint /todos in json…
lukassz
  • 3,135
  • 7
  • 32
  • 72
1
vote
1 answer

scotty doesn't detect if the port is already in use?

I'm running with this example. And it works. However, if I ran another instance, I expect it to crash with an exception, but didn't. The expected exception should say something like "Port 3000 already in use", which is a similar error when you run…
Leo Zhang
  • 3,040
  • 3
  • 24
  • 38
1
vote
1 answer

How do I set a cookie with Scotty / wai?

I've browsed the Scotty documentation but I only see the ability to set an HTTP header which seem a bit low level. Is there a more elegant way to achieve this? Third party libraries? From what I can find, a solution would be to use mapHeader from…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1
vote
1 answer

Scotty api with mysql simple in haskell

I am following this tutorial which uses scotty with persistent to create a simple API . However, I am trying to create a simple api with scotty and mysql simple library. Now I am stuck at one point in code . In the below code I am not able to…
navin
  • 165
  • 1
  • 12
1
vote
1 answer

How to log to terminal using scotty with Intellij (Haskell plugin)?

So I'm having something odd happen. Here's an illustrative code example: main :: IO () main = do scotty 8000 $ do get "/" serve where serve :: ActionM () serve = do liftIO $ print "I'm about to serve a request!" My message…
Enis
  • 171
  • 9
1
vote
1 answer

Haskell database query inside ScottyM() function

I'm trying to write simple rest API. I use Database.SQLite.Simple, Scotty and Aeson. I have a problem with DB query inside ScottyM() route function. When I have something like this routes :: [User] -> ScottyM () routes allUsers = do get…
maciej
  • 357
  • 2
  • 11
1
vote
1 answer

Scotty with Persistent and Hspec-wai

Problem trying to unit test routes. Scotty, Persistent, and Hspec-WAI. Unlike Yesod or Spock, Scotty doesn't have a nice place to store database handlers. I've got it working by having one massive "do" that starts up the database, keeps the database…
Chad Brewbaker
  • 2,523
  • 2
  • 19
  • 26
1
vote
1 answer

Scotty + Html -> how to intertwine them?

How can I work with html pages, including html templates, in Scotty? But not via Blaze because I don't like describing its structure in haskell code. It think I should heist, but how exactly to intertwine it with Scotty?
Mario
  • 185
  • 9
1
vote
1 answer

Which factors determine the appropriate value for settingsFork in a Warp application?

In Warp applications, the settingsFork option is available on the Settings data type. This allows one to choose a different fork model. When should this be set to something other than the default (void . forkIOWithUnmask)? Which factors should be…
flightlessbird
  • 413
  • 3
  • 9
1
vote
1 answer

How to use warp-tls instead of warp with scotty?

I need to start my scotty application with warp-tls instead of plain warp server but is seems running warp is hardwired in scotty's source code. Am I missing something obvious?
insitu
  • 4,488
  • 3
  • 25
  • 42