Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

I has implemented custom static path, fixed #130 #131

Open
wants to merge 7 commits into from
This page is out of date. Refresh to see the latest.
Showing with 34 additions and 6 deletions.
  1. +4 −1 .gitignore
  2. +25 −0 web/httpserver.py
  3. +5 −5 web/template.py
View
5 .gitignore 100644 → 100755
@@ -1,2 +1,5 @@
*.pyc
-.DS_Store
+.DS_Store
+build/
+dist/
+.idea/
View
25 web/httpserver.py
@@ -203,6 +203,31 @@ def __init__(self, environ, start_response):
self.environ = environ
self.start_response = start_response
+ def translate_path(self, path):
+ """Translate a /-separated PATH to the local filename syntax.
+
+ Components that mean special things to the local file system
+ (e.g. drive or directory names) are ignored. (XXX They should
+ probably be diagnosed.)
+
+ """
+ # abandon query parameters
+ path = path.split('?',1)[0]
+ path = path.split('#',1)[0]
+ path = posixpath.normpath(urllib.unquote(path))
+ words = path.split('/')
+ words = filter(None, words)
+ if hasattr(web.config, "static_path"):
+ path = os.path.dirname(web.config.static_path)
+ else:
+ path = os.getcwd()
+ for word in words:
+ drive, word = os.path.splitdrive(word)
+ head, word = os.path.split(word)
+ if word in (os.curdir, os.pardir): continue
+ path = os.path.join(path, word)
+ return path
+
def send_response(self, status, msg=""):
self.status = str(status) + " " + msg
View
10 web/template.py
@@ -1049,11 +1049,11 @@ def _load_template(self, name):
render = Render
# setup render for Google App Engine.
-try:
- from google import appengine
- render = Render = GAE_Render
-except ImportError:
- pass
+# try:
+# from google import appengine
+# render = Render = GAE_Render
+#except ImportError:
+# pass
def frender(path, **keywords):
"""Creates a template from the given file path.
Something went wrong with that request. Please try again.