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 Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes
import Control.Monad.IO.Class
main :: IO ()
main = do
scotty 3000 $ do
middleware logStdoutDev
middleware $ staticPolicy (noDots >-> addBase "static")
get "/" $ do
html $ renderHtml $
H.docTypeHtml $
H.html $ do
H.head $
H.link H.! rel "stylesheet" H.! href "stylesheet.css"
H.body $ do
H.h1 "Link Shortener"
H.form H.! method "POST" H.! action "/shorten" $ do
H.input H.! type_ "text" H.! name "url"
H.input H.! type_ "submit" H.! value "Shorten!"
post "/shorten" $ do
url <- param "url"
liftIO $ putStrLn url
redirect "/"
and the following directory structure (this is in a stack
project):
As far as I can tell from reading around, a GET request to /stylesheet.css
should serve the stylesheet, but I get a 404. A request to /static/stylesheet.css
is also a 404. Is there a problem with my middleware policy or directory structure?