It would be nice if webpy didn't force "static/" for statically served
files.

If you work around this with modrewrite/lighttpd/apache people like me
can't figure out how to make the built in server work do this sort or
rewriting. Testing with the bultin is nice.

How about letting the user set: web.config.staticdirs = ['/images/', '/
scripts/'] etc...?


>From 47a9f947f4b28af835d2a3bfad98f00c2c0534d5 Mon Sep 17 00:00:00 2001
From: Hudson Lee <[email protected]>
Date: Sun, 11 Apr 2010 08:53:30 -0400
Subject: [PATCH] Added the option for additional statically served
file directories. Simply set: web.config.staticdirs = ['/images/', '/
scripts/']

---
 web/httpserver.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/web/httpserver.py b/web/httpserver.py
index f2c91cc..544cfa4 100644
--- a/web/httpserver.py
+++ b/web/httpserver.py
@@ -208,8 +208,11 @@ class StaticMiddleware:
         path = environ.get('PATH_INFO', '')
         if path.startswith(self.prefix):
             return StaticApp(environ, start_response)
-        else:
-            return self.app(environ, start_response)
+        elif hasattr(web.config,'staticdirs'):
+            for d in web.config.staticdirs:
+                if path.startswith(d):
+                    return StaticApp(environ, start_response)
+        return self.app(environ, start_response)

 class LogMiddleware:
     """WSGI middleware for logging the status."""
--
1.7.0

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to