summaryrefslogtreecommitdiff
path: root/src/server/pgf-http.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-12-17 15:55:14 +0000
committerhallgren <hallgren@chalmers.se>2013-12-17 15:55:14 +0000
commite9e919e6e3bd92ef6c30181817dd9c6e571011de (patch)
treec975b2711f1de6c8117fdec2627847cad5e6617f /src/server/pgf-http.hs
parentc8b8ca33c65720663908f9a9d3516534f6300114 (diff)
src/server/gf-server.cabal: compile it as a common library + executables
Diffstat (limited to 'src/server/pgf-http.hs')
-rw-r--r--src/server/pgf-http.hs49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/server/pgf-http.hs b/src/server/pgf-http.hs
deleted file mode 100644
index 565843047..000000000
--- a/src/server/pgf-http.hs
+++ /dev/null
@@ -1,49 +0,0 @@
-
-import Network.CGI(requestMethod,getVarWithDefault,logCGI,handleErrors,liftIO)
-import System.Environment(getArgs)
-import System.Directory(getDirectoryContents)
-import System.FilePath(takeExtension,takeFileName,takeDirectory,(</>))
-
-import RunHTTP(runHTTP,Options(..))
-import ServeStaticFile(serveStaticFile)
-import PGFService(cgiMain',getPath,stderrToFile,logFile,newPGFCache)
-import FastCGIUtils(outputJSONP,handleCGIErrors)
-
-import Paths_gf_server(getDataDir)
-
-main :: IO ()
-main = do datadir <- getDataDir
- let defaults = Options { documentRoot = datadir</>"www",
- port = 41296 }
- cache <- newPGFCache
- args <- getArgs
- options <- case args of
- [] -> return defaults
- [port] -> do p <- readIO port
- return defaults{port=p}
- putStrLn $ "Starting HTTP server, open http://localhost:"
- ++show (port options)++"/ in your web browser.\n"
- print options
- putStrLn $ "logFile="++logFile
- stderrToFile logFile
- httpMain cache options
-
-
-httpMain cache options = runHTTP options (do log ; serve =<< getPath)
- where
- log = do method <- requestMethod
- uri <- getVarWithDefault "REQUEST_URI" "-"
- logCGI $ method++" "++uri
-
- serve path =
- handleErrors . handleCGIErrors $
- if takeExtension path==".pgf"
- then cgiMain' cache path
- else if takeFileName path=="grammars.cgi"
- then grammarList (takeDirectory path)
- else serveStaticFile path
-
- grammarList dir =
- do paths <- liftIO $ getDirectoryContents dir
- let pgfs = [path|path<-paths, takeExtension path==".pgf"]
- outputJSONP pgfs