Fetching contributors…
Cannot retrieve contributors at this time
executable file 59 lines (40 sloc) 2.06 KB
#!/usr/bin/env python
""" will serve your cache.
This script is intended to be run directly from the command line.
It is intended for direct use only during development or for debugging TileStache.
For the proper way to configure TileStach for serving tiles see the docs at:
To use this built-in server, install werkzeug and then run
By default the script looks for a config file named tilestache.cfg in the current directory and then serves tiles on
You can then open your browser and view a url like:
The above layer of 'osm' (defined in the tilestache.cfg) will display an OpenStreetMap
tile proxied from
Check --help to change these defaults.
from __future__ import print_function
if __name__ == '__main__':
from datetime import datetime
from optparse import OptionParser, OptionValueError
import os, sys
parser = OptionParser()
parser.add_option("-c", "--config", dest="file", default="tilestache.cfg",
help="the path to the tilestache config")
parser.add_option("-i", "--ip", dest="ip", default="",
help="the IP address to listen on")
parser.add_option("-p", "--port", dest="port", type="int", default=8080,
help="the port number to listen on")
parser.add_option('--include-path', dest='include',
help="Add the following colon-separated list of paths to Python's include path (aka sys.path)")
(options, args) = parser.parse_args()
if options.include:
for p in options.include.split(':'):
sys.path.insert(0, p)
from werkzeug.serving import run_simple
import TileStache
if not os.path.exists(options.file):
print("Config file not found. Use -c to pick a tilestache config file.", file=sys.stderr)
app = TileStache.WSGITileServer(config=options.file, autoreload=True)
run_simple(options.ip, options.port, app)