module Main where

import Network.CGI
import Data.Maybe

import DB

main = runCGI $ handleErrors cgiMain

cgiMain = do
    subject <- getInput "subject"
    let subj = fromJust subject
    cert <- liftIO $ db_firstvalue $ "SELECT data FROM certificates WHERE subject LIKE '" ++ subj ++ "'"
    setHeader "Content-Type" "text/plain"
    output $ cert
