Skip to content

Instantly share code, notes, and snippets.

@Themanwithoutaplan
Created March 26, 2012 14:06
Show Gist options
  • Save Themanwithoutaplan/2205313 to your computer and use it in GitHub Desktop.
Save Themanwithoutaplan/2205313 to your computer and use it in GitHub Desktop.
Calling the view raises an error on Windows because of an invalid path name.
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
</head>
<body>
<h1>${title}</h1>
</body>
</html>
# -*- coding: utf-8 -*-
from pyramid.config import Configurator
from pyramid.view import view_config
from wsgiref.simple_server import make_server
@view_config(renderer='__main__:templates/index.mako') # found via traversal
def test_page(request):
title = 'Pyramid Debugtoolbar'
return {
'title': title,
}
class DummyRootFactory(object):
def __init__(self, request):
self.request = request
def __getitem__(self, name):
return self
if __name__ == '__main__':
# configuration settings
settings = {}
settings['debug_templates'] = True
settings['reload_templates'] = True
settings['mako.directories'] = '__main__:templates'
settings['mako.module_directory'] = '__main__:mako_modules'
# configuration setup
config = Configurator(settings=settings,
root_factory=DummyRootFactory)
# routes setup
config.scan('__main__')
app = config.make_wsgi_app()
httpd = make_server('', 8080, app)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment