2017-10-20 36 views
0

J'ai un simple serveurComment obtenir un itinéraire avec Haskell Scotty?

{-# LANGUAGE OverloadedStrings #-} 

import Web.Scotty 
import Data.Text 
import Data.Monoid (mconcat) 

server :: ScottyM() 
server = do 
    get "/" $ file "./index.html" 

Et je veux servir index.html sur toutes les routes, par exemple. get "*" $ file "./index.html", mais cela ne fonctionne pas. Comment y parvenir?

Répondre

0

Comme dans l'exemple fourni: https://github.com/scotty-web/scotty

{-# LANGUAGE OverloadedStrings #-} 
import Web.Scotty 
import Data.Monoid (mconcat) 

main = scotty 3000 $ 
    get "/:word" $ do 
     file "./index.html" 
+0

mais '' 'get "/: mot"' '' retourne 'fichier introuvable' lorsque le second PARAM est provieded avec quelque chose comme '' 'http: //hostip.com/: mot /: second_param'''. Et j'ai besoin de "*". Je sais que haskell et scotty en particulier supportent regex dans ses RoutePatterns, mais ne savent pas comment fonctionne regex, socotty regex et comment il traduit la forme String en type RoutePattern – F1ks3r