self._error(404, stream=stream)
path = _os_path.join(self._base_path, url)
if _os_path.exists(path) and not _os_path.isdir(path):
- LOG.error('nonexstand directory')
+ LOG.error('nonexistent directory')
self._error(404, stream=stream)
def serve(self, url=None, page=0, stream=None):
elif self.is_cached(url=url):
self.cached(url=url, stream=stream)
elif url.endswith('.png'):
- self.thumb(url=url, stream=stream)
+ self._thumb(url=url, stream=stream)
else:
self.validate_url(url=url, stream=stream)
self.page(url=url, page=page, stream=stream)
pass
server.serve(url=url, page=page, stream=sys.stdout)
-def serve_scgi(server, port=4000):
+def serve_scgi(server, host='localhost', port=4000):
import scgi
import scgi.scgi_server
import urlparse
server.serve(url=url, page=page, stream=output)
s = scgi.scgi_server.SCGIServer(
- handler_class=GalleryHandler, host='localhost', port=port)
- LOG.info('serving SCGI')
+ handler_class=GalleryHandler, host=host, port=port)
+ LOG.info('serving SCGI on {}:{}'.format(host, port))
s.serve()
if __name__ == '__main__':
import argparse as _argparse
- parser = _argparse.ArgumentParser(description=__doc__, version=__version__)
+ parser = _argparse.ArgumentParser(
+ description=__doc__, version=__version__,
+ formatter_class=_argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--scgi', default=False, action='store_const', const=True,
help='Run as a SCGI server (vs. serving a single CGI call)')
parser.add_argument(
- '--base-path', default='/var/www/localhost/htdocs/gallery/',
+ '--port', default=4000, type=int,
+ help='Port to listen to (if runing as a SCGI server)')
+ parser.add_argument(
+ '--base-path', default='.',
help='Path to the root gallery source')
parser.add_argument(
- '--base-url', default='/gallery/',
+ '--base-url', default='/',
help='URL for the root gallery source')
parser.add_argument(
'--shared-path', default=None,
s.footer = [open(_os_path.join(shared, 'footer.shtml'), 'r').read()]
if args.scgi:
- serve_scgi(server=s)
+ serve_scgi(server=s, port=args.port)
else:
serve_cgi(server=s)