2017-10-20 7 views
0

は、私は単純なサーバーHaskell Scottyでどのように各ルートを手に入れる?

{-# LANGUAGE OverloadedStrings #-} 

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

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

を持っていると私はすべてのルートなどでindex.htmlを提供したいです。 get "*" $ file "./index.html"しかし、それは動作しません。それを達成する方法?

提供の例と同じ

答えて

0

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

が、 '' '取得 "/:単語"' ''を返します 'ファイルが見つからない' 第二のparamが ''のようなものでproviededされます'http://hostip.com/:word /:second_param'''となります。そして私は "*"を取得する必要があります。私はhaskellとscottyが特にRoutePatternsで正規表現をサポートしていることを知っていますが、正規表現、socotty正規表現がどのように動作し、どのようにフォーム文字列をRoutePattern型に変換するかはわかりません – F1ks3r

関連する問題