Skip to content

Instantly share code, notes, and snippets.

@reinhrst
Created June 4, 2012 22:56
Show Gist options
  • Save reinhrst/2871341 to your computer and use it in GitHub Desktop.
Save reinhrst/2871341 to your computer and use it in GitHub Desktop.
Hello world of clojure + compojure + google app engine (smallest working set)
NOTE: colons in file names are directory separators (which are not allowed in gist...)
NOTE2: Actually it doesn't like colons either, so all files are here twice now and I can't remove them.... Have fun with them :)
NOTE3: Very likely the appengine dependency is not even needed. Doesn't hurt though and is most likely useful later....
These 4 files will make a project that runs on appengine.
To run:
lein dep
lein compile
$GAESDK/bin/dev_appserver.sh war
Deploy with:
$GAESDK/bin/appcfg.sh update war
Works 2012-6-5
Inspiration: http://pseudofish.com/blog/2010/09/18/learning-clojure-with-google-app-engine-and-emacs/
(defproject sopbase "1.0.0-SNAPSHOT"
:description "***"
:aot [sopbase.core]
:dependencies [[org.clojure/clojure "1.3.0"]
[compojure "1.1.0"]
[appengine "0.4.3-SNAPSHOT"]
[ring/ring-servlet "1.1.0"]]
:plugins [[lein-ring "0.7.1"]]
:ring {:handler sopbase.core/app}
:compile-path "war/WEB-INF/classes"
:library-path "war/WEB-INF/lib")
(ns sopbase.core
(:use compojure.core)
(:gen-class :extends javax.servlet.http.HttpServlet)
(:require [compojure.route :as route]
[compojure.handler :as handler]
[ring.util.servlet :as servlet]))
(defroutes main-routes
(GET "/" [] "<h1>HELLO SOPPERS</h1>It works!")
(route/resources "/")
(route/not-found "Page not found"))
(servlet/defservice main-routes)
(ns sopbase.core
(:use compojure.core)
(:gen-class :extends javax.servlet.http.HttpServlet)
(:require [compojure.route :as route]
[compojure.handler :as handler]
[ring.util.servlet :as servlet]))
(defroutes main-routes
(GET "/" [] "<h1>HELLO SOPPERS</h1>It works!")
(route/resources "/")
(route/not-found "Page not found"))
(servlet/defservice main-routes)
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>sopbase</application>
<version>1</version>
<static-files />
<resource-files />
<threadsafe>false</threadsafe>
</appengine-web-app>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Sopbase</display-name>
<servlet>
<servlet-name>sopbase</servlet-name>
<servlet-class>sopbase.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sopbase</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>sopbase</application>
<version>1</version>
<static-files />
<resource-files />
<threadsafe>false</threadsafe>
</appengine-web-app>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Sopbase</display-name>
<servlet>
<servlet-name>sopbase</servlet-name>
<servlet-class>sopbase.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sopbase</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment