diff options
| author | hallgren <hallgren@chalmers.se> | 2011-10-12 17:03:54 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2011-10-12 17:03:54 +0000 |
| commit | 44d1a5a9f71b03d9aceeccd760a63fcdc45f8bad (patch) | |
| tree | d51076a708997d6f1af6ac0deefd535bbc25f804 /src/compiler/GFServer.hs | |
| parent | 0aba45560d2033c37c3d2e876e6f3ef89e1554d6 (diff) | |
Improvements of "gf -server" mode and related setup
"gf -server" mode now contains everything needed to run the minibar and
the grammar editor (including example-based grammar writing).
The Setup.hs script installs the required files where gf -server can find them.
These files have been moved to a new directory: src/www.
The separate server program pgf-http is now obsolete.
Diffstat (limited to 'src/compiler/GFServer.hs')
| -rw-r--r-- | src/compiler/GFServer.hs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index 6e9b26a8d..bc5bdbdaf 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -27,21 +27,19 @@ import qualified ExampleService as ES import Paths_gf(getDataDir) import RunHTTP(Options(..),cgiHandler) --- * Configuraiton - -options = Options { documentRoot = "." {-datadir</>"www"-}, port = gfport } -gfport = 41296 - -- * HTTP server server execute1 state0 = do state <- newMVar M.empty cache <- PS.newPGFCache - --datadir <- getDataDir - putStrLn $ "Starting server on port "++show gfport - initServer gfport (modifyMVar state . handle state0 cache execute1) + datadir <- getDataDir + let options = Options { documentRoot = datadir</>"www", port = 41296 } + putStrLn $ "Starting HTTP server, open http://localhost:" + ++show (port options)++"/ in your web browser." + initServer (port options) + (modifyMVar state . handle options state0 cache execute1) -- * HTTP request handler -handle state0 cache execute1 +handle options state0 cache execute1 rq@(Request method URI{uriPath=upath,uriQuery=q} hdrs body) state = do let qs = decodeQ $ case method of @@ -67,6 +65,8 @@ handle state0 cache execute1 where root = documentRoot options + translatePath rpath = root</>rpath -- hmm, check for ".." + wrapCGI cgi = do resp <- cgiHandler root (handleErrors . handleCGIErrors $ cgi) rq return (state,resp) @@ -191,8 +191,6 @@ escape1 c = [c] -- * Static content -translatePath path = documentRoot options</>path -- hmm, check for ".." - serveStaticFile path = do b <- doesDirectoryExist path let path' = if b then path </> "index.html" else path |
