From 9df3e5c027e88aef3e0c4e4010d91af398ecc978 Mon Sep 17 00:00:00 2001
From: Robohash <401330+e1ven@users.noreply.github.com>
Date: Tue, 6 Nov 2012 17:37:39 -0500
Subject: [PATCH] Cleaned up directoryparam support

---
 requirements.txt    |  2 +-
 templates/root.html |  1 +
 webfront.py         | 12 ++++++------
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index 8b48bf3..f0d3196 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
 PIL==1.1.7
 distribute==0.6.27
-tornado==2.4
+tornado==1.2.1
 wsgiref==0.1.2
diff --git a/templates/root.html b/templates/root.html
index 6f90642..589dce2 100644
--- a/templates/root.html
+++ b/templates/root.html
@@ -547,6 +547,7 @@ src="//static1.robohash.org/static/img/indented_star.png" width="27" height="25"
     For example: http://robohash.org/colin@robohash.org?gravatar=yes<br> or http://robohash.org/620050a4db5104bae758cd75171d64ca?gravatar=hashed
     </p><p>
     <p>Both traditional and new Stealthy (https) robots are available.</p> 
+    <p>We've also conditioned our robots to accept commands either via params or directories-<br> For instance http://127.0.0.1:8080/set_set3/bgset_bg1/3.14159?size=500x500
     <p>Finally, the <a href="http://github.com/e1ven/Robohash">Blueprints are available</a> to build your own robotic
     factory.</p>
 </p>
diff --git a/webfront.py b/webfront.py
index a3be2ca..5c5192d 100755
--- a/webfront.py
+++ b/webfront.py
@@ -230,16 +230,16 @@ class ImgHandler(tornado.web.RequestHandler):
               args[k] = args[k][0]
             else:
               args[k] = ""
-        
+
+        # IF, and Only IF, there is an arg in the list, should we interpret slashes as params
         split = string.split('/')
-        if len(split) > 0:
-            string = split[0]
-        
         if len(split) > 1:
-          for str in split[1::]:
+          for str in split:
             b = str.encode('ascii','ignore').split('_')
             if len(b) == 2:
-              args[b[0]] = b[1]
+              if b[0] in ['gravatar','ignoreext','size','set','bgset']:
+                args[b[0]] = b[1]
+                string = split[len(split)-1]
 
         colors = ['blue','brown','green','grey','orange','pink','purple','red','white','yellow']
         sets = ['set1','set2','set3']