Advertisement
Guest User

Untitled

a guest
Nov 18th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns causemap-parse.handler
  2.   (:require [compojure.core :refer :all]
  3.             [compojure.handler :as handler]
  4.             [compojure.route :as route]
  5.             [ring.middleware.cors :refer [wrap-cors]]
  6.             [ring.util.response :refer [resource-response response]]
  7.             [ring.middleware.json :as middleware]
  8.             [duckling.core :as p]))
  9.  
  10. (p/load!) ;; Load default configuration
  11.  
  12. (defroutes app-routes
  13.   (POST "/" request (response (p/parse :en$core ;; core configuration for English ; see also :fr$core, :es$core, :cn$core
  14.          (get-in request [:body :period])
  15.          [:time])))
  16.   (route/resources "/")
  17.   (route/not-found "Not Found"))
  18.  
  19. (def app
  20.   (-> (handler/site app-routes)
  21.       (wrap-cors :access-control-allow-origin #"http://localhost:3000"
  22.         :access-control-allow-methods [:post])
  23.       (middleware/wrap-json-body {:keywords? true})
  24.       (middleware/wrap-json-response)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement