Something resembling of a front page
This commit is contained in:
		
							
								
								
									
										43
									
								
								src/API.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/API.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
{-# Language DataKinds #-}
 | 
			
		||||
{-# Language TypeFamilies #-}
 | 
			
		||||
{-# Language TypeOperators #-}
 | 
			
		||||
{-# Language NoImplicitPrelude #-}
 | 
			
		||||
{-# Language MultiParamTypeClasses #-}
 | 
			
		||||
{-# Language OverloadedStrings #-}
 | 
			
		||||
{-# Language TemplateHaskell #-}
 | 
			
		||||
{-# Language QuasiQuotes #-}
 | 
			
		||||
{-# Language RecordWildCards #-}
 | 
			
		||||
{-# Language DeriveGeneric #-}
 | 
			
		||||
{-# Language FlexibleInstances #-}
 | 
			
		||||
module API (API, handler) where
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import ClassyPrelude hiding (Handler, Index)
 | 
			
		||||
import Servant
 | 
			
		||||
import Servant.HTML.Lucid (HTML)
 | 
			
		||||
import Lucid (HtmlT, ToHtml(..))
 | 
			
		||||
import qualified Lucid.Html5 as H
 | 
			
		||||
 | 
			
		||||
data Index = Index
 | 
			
		||||
 | 
			
		||||
bulma :: Monad m => HtmlT m ()
 | 
			
		||||
bulma = H.doctypehtml_ $ do
 | 
			
		||||
  H.meta_ [ H.name_ "viewport", H.content_ "width=device-width, initial-scale=1" ]
 | 
			
		||||
  H.meta_ [ H.charset_ "utf-8" ]
 | 
			
		||||
  H.title_ "Hello bulma!"
 | 
			
		||||
  H.link_ [ H.rel_ "stylesheet", H.href_ "/static/css/bulma.min.css" ]
 | 
			
		||||
  H.script_ [ H.defer_ "", H.src_ "https://use.fontawesome.com/releases/v5.1.0/js/all.js" ] ("" :: String)
 | 
			
		||||
  H.body_ $ do
 | 
			
		||||
    H.section_ [ H.class_ "section" ] $ do
 | 
			
		||||
      H.div_ [ H.class_ "container" ] $ do
 | 
			
		||||
        H.h1_ [ H.class_ "title" ] "Hello world"
 | 
			
		||||
        H.p_ [ H.class_ "subtitle" ] "My first website with bulma"
 | 
			
		||||
 | 
			
		||||
instance ToHtml Index where
 | 
			
		||||
  toHtml _ = bulma
 | 
			
		||||
  toHtmlRaw = toHtml
 | 
			
		||||
 | 
			
		||||
type API = Get '[HTML] Index
 | 
			
		||||
 | 
			
		||||
handler :: ServerT API Handler
 | 
			
		||||
handler = return Index
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
module Main where
 | 
			
		||||
 | 
			
		||||
import Server (server)
 | 
			
		||||
import Network.Wai.Handler.Warp (run)
 | 
			
		||||
 | 
			
		||||
defaultMain :: IO ()
 | 
			
		||||
defaultMain = putStrLn "Hello haskell"
 | 
			
		||||
defaultMain = run 8080 server
 | 
			
		||||
 | 
			
		||||
main :: IO ()
 | 
			
		||||
main = defaultMain
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								src/Server.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/Server.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
{-# Language DataKinds #-}
 | 
			
		||||
{-# Language TypeFamilies #-}
 | 
			
		||||
{-# Language TypeOperators #-}
 | 
			
		||||
{-# Language NoImplicitPrelude #-}
 | 
			
		||||
{-# Language MultiParamTypeClasses #-}
 | 
			
		||||
{-# Language OverloadedStrings #-}
 | 
			
		||||
{-# Language TemplateHaskell #-}
 | 
			
		||||
{-# Language QuasiQuotes #-}
 | 
			
		||||
{-# Language RecordWildCards #-}
 | 
			
		||||
{-# Language DeriveGeneric #-}
 | 
			
		||||
{-# Language FlexibleInstances #-}
 | 
			
		||||
module Server where
 | 
			
		||||
 | 
			
		||||
import qualified API as API
 | 
			
		||||
import Servant
 | 
			
		||||
 | 
			
		||||
type API = API.API :<|> "static" :> Raw
 | 
			
		||||
 | 
			
		||||
handler :: ServerT API Handler
 | 
			
		||||
handler = API.handler :<|> serveDirectoryFileServer "static"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
server :: Application
 | 
			
		||||
server = serve api handler
 | 
			
		||||
  where
 | 
			
		||||
    api :: Proxy API
 | 
			
		||||
    api = Proxy
 | 
			
		||||
		Reference in New Issue
	
	Block a user