Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Created September 25, 2017 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarstenKoenig/dc342e424178ffe3b9783f54b47d8d74 to your computer and use it in GitHub Desktop.
Save CarstenKoenig/dc342e424178ffe3b9783f54b47d8d74 to your computer and use it in GitHub Desktop.
Demonstration of getting a scotty server running as a script - needs stack
#!/usr/bin/env stack
-- stack --resolver lts-9.5 script --package scotty
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Data.Monoid (mconcat)
main = scotty 3000 $ do
get "/:word" $ do
beam <- param "word"
html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
@CarstenKoenig
Copy link
Author

CarstenKoenig commented Sep 25, 2017

make sure you have stack installed

after you just have to

chmod +x ScottyScriptDemo.hs

and then you can run it using

./ScottyScriptDemo.hs

beware: the first start might take some time (getting/compiling the dependencies) - after it should be much quicker

you can visit the demo site just by browsing to http://localhost:3000


Disclaimer: that's 100% code from the Scotty documentation plus the Stack docs - I only copy&pasted ;)

@CarstenKoenig
Copy link
Author

CarstenKoenig commented Sep 25, 2017

btw: there is just a single route you can test by http://localhost:3000/Haskell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment