From 421f44e47a426151ea2110c51692f9a2917cb803 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Wed, 24 Oct 2018 11:47:48 -0700 Subject: [PATCH] serving/helloworld-haskell: respect the port env var (#463) --- serving/samples/helloworld-haskell/README.md | 8 +++++--- serving/samples/helloworld-haskell/app/Main.hs | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/serving/samples/helloworld-haskell/README.md b/serving/samples/helloworld-haskell/README.md index e5a5d9b6d..effdada2a 100644 --- a/serving/samples/helloworld-haskell/README.md +++ b/serving/samples/helloworld-haskell/README.md @@ -63,9 +63,11 @@ following instructions recreate the source files from this folder. import Web.Scotty.Trans main :: IO () - main = do - t <- fromMaybe "World" <$> lookupEnv "TARGET" - scotty 8080 (route t) + main = do + t <- fromMaybe "World" <$> lookupEnv "TARGET" + pStr <- fromMaybe "8080" <$> lookupEnv "PORT" + let p = read pStr :: Int + scotty p (route t) route :: String -> ScottyM() route t = get "/" $ hello t diff --git a/serving/samples/helloworld-haskell/app/Main.hs b/serving/samples/helloworld-haskell/app/Main.hs index b16fc5f6a..0e35f7cbf 100644 --- a/serving/samples/helloworld-haskell/app/Main.hs +++ b/serving/samples/helloworld-haskell/app/Main.hs @@ -11,7 +11,9 @@ import Web.Scotty.Trans main :: IO () main = do t <- fromMaybe "World" <$> lookupEnv "TARGET" - scotty 8080 (route t) + pStr <- fromMaybe "8080" <$> lookupEnv "PORT" + let p = read pStr :: Int + scotty p (route t) route :: String -> ScottyM() route t = get "/" $ hello t