<commit_before>{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}

module Main where

import           Control.Applicative
import           Control.Monad
import           Data.Maybe
import           Control.Monad.IO.Class
import           Data.List                      ( sort )
import           Safe                           ( readMay )

import           Snap.Core
import           Snap.Util.FileServe
import           Snap.Http.Server        hiding ( Config )

import           Diagrams.Prelude        hiding ( Result
                                                , (.=)
                                                , render
                                                )

import qualified Data.Aeson                    as J
import           Data.Yaml

import           Parse.Code                     ( parseCode )
import           Draw.Code                      ( drawCode )
import           Draw.CmdLine
import           Draw.Draw
import           Data.Compose
import           Parse.Puzzle
import           Data.PuzzleTypes
import           Draw.Font                      ( fontAnelizaRegular
                                                , fontBit
                                                )
import           Draw.Lib                       ( Backend' )

import qualified Data.ByteString.Char8         as C
import qualified Data.ByteString               as B
import qualified Data.ByteString.Lazy          as BL

import           System.Directory
import           System.FilePath.Posix
import           Data.List                      ( stripPrefix )

main :: IO ()
main = quickHttpServe site

site :: Snap ()
site =
  ifTop (serveFile "static/index.html")
    <|> route
          [ ("/api/preview" , previewPostHandler)
          , ("/api/download", downloadPostHandler)
          , ("/api/examples", examplesGetHandler)
          ]
    <|> serveDirectory "static"<commit_msg>handle the redirect from puzzle-draw-demo.herokuapp.com<commit_after>{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}

module Main where

import           Control.Applicative
import           Control.Monad
import           Data.Maybe
import           Control.Monad.IO.Class
import           Data.List                      ( sort )
import           Safe                           ( readMay )

import           Snap.Core
import           Snap.Util.FileServe
import           Snap.Http.Server        hiding ( Config )

import           Diagrams.Prelude        hiding ( Result
                                                , (.=)
                                                , render
                                                )

import qualified Data.Aeson                    as J
import           Data.Yaml

import           Parse.Code                     ( parseCode )
import           Draw.Code                      ( drawCode )
import           Draw.CmdLine
import           Draw.Draw
import           Data.Compose
import           Parse.Puzzle
import           Data.PuzzleTypes
import           Draw.Font                      ( fontAnelizaRegular
                                                , fontBit
                                                )
import           Draw.Lib                       ( Backend' )

import qualified Data.ByteString.Char8         as C
import qualified Data.ByteString               as B
import qualified Data.ByteString.Lazy          as BL

import           System.Directory
import           System.FilePath.Posix
import           Data.List                      ( stripPrefix )

main :: IO ()
main = quickHttpServe site

site :: Snap ()
site =
  ifTop (serveFile "static/index.html")
    <|> route [ ("/static/puzzle.html", redirect "/") ] -- old demo redirect
    <|> route
          [ ("/api/preview" , previewPostHandler)
          , ("/api/download", downloadPostHandler)
          , ("/api/examples", examplesGetHandler)
          ]
    <|> serveDirectory "static"
{'fraction_non_alphanumeric': 0.07179739365625769, 'fraction_numerical': 0.0004917629702483403, 'mean_word_length': 1.1121495327102804, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2438238', 'n_tokens_mistral': 958, 'n_tokens_neox': 925, 'n_words': 231}