From a7548f3da3897cd8bb247c784c50d39d642623b9 Mon Sep 17 00:00:00 2001 From: Lia Lenckowski Date: Sun, 15 Oct 2023 18:42:04 +0200 Subject: embed resources into executable --- src/Main.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index d69ced6..03709d4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -11,6 +11,7 @@ import Control.Monad.Trans.Resource (runResourceT) import Control.Monad (when, unless) import Database.Persist.Sqlite import Data.Bool (bool) +import Data.FileEmbed (embedFile) import Data.Function ((&)) import Data.Pool (Pool) import Network.Wai.Handler.Warp hiding (getPort, getHost) @@ -53,20 +54,20 @@ instance YesodPersist Search where runDB action = getYesod >>= runSqlPool action . sqlPool -getHomeR :: Handler () +getHomeR :: Handler TypedContent getHomeR = do cacheSeconds $ 60 * 60 * 24 * 7 - sendFile typeHtml "index.html" + return $ TypedContent typeHtml $ toContent ($(embedFile "build/index.html")) -getBundleR :: Handler () +getBundleR :: Handler TypedContent getBundleR = do cacheSeconds $ 60 * 60 * 24 * 7 - sendFile typeJavascript "bundle.js" + return $ TypedContent typeJavascript $ toContent ($(embedFile "build/bundle.js")) -getStyleR :: Handler () +getStyleR :: Handler TypedContent getStyleR = do cacheSeconds $ 60 * 60 * 24 * 7 - sendFile typeCss "style.css" + return $ TypedContent typeCss $ toContent ($(embedFile "build/style.css")) getBangsR :: Handler TypedContent getBangsR = do -- cgit v1.2.3-70-g09d2