{"id":6218,"date":"2011-10-05T00:08:09","date_gmt":"2011-10-04T15:08:09","guid":{"rendered":"http:\/\/fukata.org\/?p=6218"},"modified":"2017-08-11T22:58:49","modified_gmt":"2017-08-11T22:58:49","slug":"compojure-static-files","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6218\/","title":{"rendered":"Compojure\u3067\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u4fe1"},"content":{"rendered":"
\u524d\u56de\u3001DB\u63a5\u7d9a\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5229\u7528\u307e\u3067\u66f8\u3044\u305f\u3093\u3067\u3059\u304c\u3001\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u4fe1\u3059\u308b\u4ed5\u7d44\u307f\u304c\u307e\u3060\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3068\u4e0b\u8a18\u304c\u7c21\u5358\u3067\u3057\u305f\u3002<\/p>\n
Clojure\u306e\u5165\u9580\u304c\u3066\u3089\u3001Heroku\u306b\u81ea\u5206\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30b5\u30a4\u30c8\u3092\u4f5c\u3063\u3066\u307f\u308b \u305d\u306e\u3044\u3061 – \u87f2\uff01\u866b\uff01\u87f2\uff01 – #!\/usr\/bin\/bugrammer<\/a><\/p>\n project.clj\u306b\u300cweb-content<\/strong>\u300d\u3068\u3044\u3046\u9805\u76ee\u3092\u8ffd\u52a0\u3057\u3001\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u3069\u3053\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u4eca\u56de\u306e\u5834\u5408\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u76f4\u4e0b\u306epublic<\/strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u914d\u7f6e\u3059\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002<\/p>\n \u6b21\u306b\u3001\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u4fe1\u3059\u308b\u305f\u3081\u306b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002 src\/compojureexample\/core.clj<\/strong><\/p>\n \u4ee5\u4e0a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u524d\u56de\u3001DB\u63a5\u7d9a\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5229\u7528\u307e\u3067\u66f8\u3044\u305f\u3093\u3067\u3059\u304c\u3001\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u4fe1\u3059\u308b\u4ed5\u7d44\u307f\u304c\u307e\u3060\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3068\u4e0b\u8a18\u304c\u7c21\u5358\u3067\u3057\u305f\u3002 Clojure\u306e\u5165\u9580\u304c\u3066\u3089\u3001Heroku\u306b\u81ea\u5206\u306e\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30b5\u30a4\u30c8\u3092 … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[900],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6218"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=6218"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6218\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=6218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=6218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=6218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u306e\u914d\u7f6e\u5834\u6240<\/h2>\n
\r\n(defproject compojureexample \"1.0.0-SNAPSHOT\"\r\n :description \"Compojure Example\"\r\n :dependencies [[org.clojure\/clojure \"1.2.0\"]\r\n [org.clojure\/clojure-contrib \"1.2.0\"]\r\n [compojure \"0.6.5\"]\r\n [ring\/ring-jetty-adapter \"0.3.9\"]]\r\n;; \u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u914d\u7f6e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\r\n :web-content \"public\")\r\n<\/pre>\n
\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n
\n\u4eca\u56de\u306f\u3001public\u76f4\u4e0b\u306b\u914d\u7f6e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3001URL\u3068\u3057\u3066\u306f\u3001static\u4ee5\u4e0b\u304cpublic\u76f4\u4e0b\u3092\u53c2\u7167\u3059\u308b\u611f\u3058\u3067\u3001\u300chttps:\/\/localhost:8080\/static\/***\u300d\u306e\u3088\u3046\u306b\u30a2\u30af\u30bb\u30b9\u3055\u305b\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\r\n(ns compojureexample.core\r\n (:use compojure.core\r\n compojure.response\r\n ring.adapter.jetty)\r\n (:require [compojure.route :as route]))\r\n\r\n;; =============================================\r\n;; Routes\r\n;; =============================================\r\n(defroutes app\r\n (GET \"\/\" _ \"Hello World\")\r\n;; https:\/\/localhost:8080\/***\u3068\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3055\u305b\u305f\u3044\u5834\u5408\u306f\u3001\u300c\/\u300d\u3060\u3051\u3067\u3088\u3044\u3002\r\n (route\/files \"\/static\/\"))\r\n\r\n;; =============================================\r\n;; Run Server\r\n;; =============================================\r\n(defn -main []\r\n (let [port (Integer\/parseInt (get (System\/getenv) \"PORT\" \"8080\"))]\r\n (run-jetty app {:port port})))\r\n<\/pre>\n