Guest User

Untitled

a guest
Jun 4th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. (ns fy_hrp275.core
  2. (:use compojure.core)
  3. (:use ring.util.response)
  4. (:use ring.middleware.reload)
  5. (:use ring.middleware.stacktrace)
  6. (:use ring.middleware.file)
  7. (:use ring.middleware.file-info)
  8. (:use hiccup.core)
  9. (:use hiccup.page-helpers)
  10. (:use clojure.contrib.sql)
  11. (:use fy_hrp275.middleware))
  12.  
  13. (def *db*
  14. {:classname "net.sourceforge.jtds.jdbc.Driver"
  15. :subprotocol "jtds"
  16. :subname "sqlserver://10.0.1.12/hrp275;user=sa;password=rxmx1199"})
  17.  
  18. (defn view-layout [& content]
  19. (html
  20. (doctype :xhtml-strict)
  21. (xhtml-tag "en"
  22. [:head
  23. [:meta {:http-equiv "Content-Type"
  24. :content "text/html; charset=utf8"}]
  25. [:title "Test"]
  26. [:link {:href "/test.css" :rel "stylesheet" :type "text/css"}]]
  27. [:body content])))
  28.  
  29. (defn tag_h [tag]
  30. (str "<" tag ">"))
  31.  
  32. (defn tag_t [tag]
  33. (str "</" tag ">"))
  34.  
  35. (defn view-test []
  36. (view-layout
  37. ;; (with-connection *db*
  38. ;; (with-query-results rs ["select top 10 * from gy_ksdm"]
  39. ;; (let [ta1 (tag_h "table") ta2 (tag_t "table")
  40. ;; th1 (tag_h "th") th2 (tag_t "th")
  41. ;; td1 (tag_h "td") td2 (tag_t "td")
  42. ;; tr1 (tag_h "tr") tr2 (tag_t "tr")]
  43. ;; (doall (map (fn [x]
  44. ;; (str tr1
  45. ;; (str td1 (:ksdm x) td2)
  46. ;; (str td1 (:ksmc x) td2) tr2)
  47. ;; ) rs)))))))
  48.  
  49. "你好"))
  50. (defroutes handler
  51. (GET "/test" []
  52. (view-test))
  53. (GET "/t1" []
  54. (java.io.ByteArrayInputStream. (.getBytes "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>刘孟江</body></html>" "UTF-8")))
  55. (GET "/t2" []
  56. (java.io.ByteArrayInputStream. (.getBytes "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>刘孟江</body></html>" "UTF-8"))
  57. ))
  58.  
  59. (wrap! handler (:charset "utf-8"))
  60.  
  61. (def app
  62. (-> #'handler
  63. ;;(wrap-file "public")
  64. ;;(wrap-file-info)
  65. (wrap-request-logging)
  66. (wrap-reload '[fy_hrp275.middleware fy_hrp275.core])
  67. (wrap-bounce-favicon)
  68. (wrap-stacktrace)))
Add Comment
Please, Sign In to add comment