Database Reference
In-Depth Information
[ring/ring-jetty-adapter "1.3.1"]
[compojure "1.2.0"]]
:plugins [[lein-ring "0.8.3"]]
:ring {:handler web-viz.web/app})
Also, we'll need data to serve. For this recipe, we'll serve the 2010 US census race data that
we've been using throughout this topic. I've converted it to JSON, though, so we can load it
into D3 more easily. You can download this ile from http://www.ericrochester.com/
clj-data-analysis/data/census-race.json .
How to do it…
Setting up a web application is relatively simple, but a number of steps are involved.
We'll create the namespace and coniguration, then we'll set up the application,
and inally we'll add resources.
Coniguring and setting up the web application
The code for the web application will need to be run again and again, so we'll need to make
sure that our code makes it into iles. Let's create a namespace inside our Leiningen project
for it. Right now, my Leiningen project is named web-viz , so I'll use it in this example, but you
should replace it with whatever your project is named. To do this, perform the following steps:
1.
Inside the project's src directory, let's create a ile named web.clj . It's full path will
be src/web_viz/web.clj . This will contain the web application and routes.
2.
We'll use this namespace declaration at the top of web.clj . Note that you'll need to
change the namespace to match your project:
(ns web-viz.web
(:require [compojure.route :as route]
[compojure.handler :as handler])
(:use compojure.core
ring.adapter.jetty
[ring.middleware.content-type
:only (wrap-content-type)]
[ring.middleware.file
:only (wrap-file)]
[ring.middleware.file-info
:only (wrap-file-info)]
[ring.middleware.stacktrace
:only (wrap-stacktrace)]
[ring.util.response
:only (redirect)] ))
 
Search WWH ::




Custom Search