Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- import Network.Wai
- import Network.HTTP.Types
- import Network.Wai.Handler.Warp (run)
- import Database.MySQL.Base
- import Data.Pool (Pool, createPool, withResource)
- newConn = do
- connect defaultConnectInfo
- { ciUser = "root"
- , ciPassword = "secret"
- , ciDatabase = "test" }
- getPool = do
- createPool newConn close 1 10 5
- app :: IO (Pool MySQLConn) -> Application
- app pool _ respond = do
- p <- pool
- withResource p $ \c -> do execute_ c "SELECT 1"
- respond $ responseLBS
- status200
- [("Content-Type", "text/plain")]
- "Hello, Web!"
- main :: IO ()
- main = do
- putStrLn $ "http://localhost:8080/"
- run 8080 $ app $ getPool
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement