--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/pngtile.fcgi Thu Jan 07 22:25:05 2010 +0200
@@ -0,0 +1,34 @@
+#!/usr/bin/env python2.5
+
+import flup.server.fcgi
+
+def main (app, bind=None) :
+ """
+ Run as a non-threaded single-process non-multiplexed FastCGI server
+ """
+
+ # create WSGIServer
+ server = flup.server.fcgi.WSGIServer(app,
+ # try to supress threading
+ multithreaded=False,
+ multiprocess=False,
+ multiplexed=False,
+
+ # specify the bind() address
+ bindAddress=bind,
+
+ # leave as defaults for now
+ umask=None,
+
+ # XXX: non-debug mode?
+ debug=True,
+ )
+
+ # run... threads :(
+ server.run()
+
+if __name__ == '__main__' :
+ import pngtile.wsgi
+
+ main(pngtile.wsgi.application)
+
--- a/pngtile/wsgi.py Thu Jan 07 22:24:30 2010 +0200
+++ b/pngtile/wsgi.py Thu Jan 07 22:25:05 2010 +0200
@@ -4,11 +4,11 @@
from werkzeug import Request, Response, responder
from werkzeug import exceptions
-import os.path
+import os.path, os
import pypngtile as pt
-DATA_ROOT = os.path.abspath('data')
+DATA_ROOT = os.environ.get("PNGTILE_DATA_PATH") or os.path.abspath('data/')
IMAGE_CACHE = {}
@@ -20,6 +20,7 @@
def dir_view (req, name, path) :
prefix = os.path.dirname(req.script_root).rstrip('/')
+ script_prefix = req.script_root
name = name.rstrip('/')
@@ -42,9 +43,9 @@
listing = "\n".join(
"""<li><a href="%(url)s">%(name)s</a></li>""" % dict(
- url = '/'.join((prefix, name, item)),
+ url = '/'.join((script_prefix, name, item)),
name = item,
- ) for item in ['..'] + os.listdir(path)
+ ) for item in ['..'] + [i for i in os.listdir(path) if i.endswith('.png') or os.path.isdir(os.path.join(path, i))]
),
)
@@ -130,6 +131,7 @@
# build absolute path
image_path = os.path.abspath(os.path.join(DATA_ROOT, image_name))
+
# ensure the path points inside the data root
if not image_path.startswith(DATA_ROOT) :