add /favicon.ico and /robots.txt views

This commit is contained in:
Lance Edgar 2012-03-23 21:06:28 -05:00
parent ce16a1cf6f
commit 925cd30b96
3 changed files with 29 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

View file

@ -26,20 +26,45 @@
``edbob.pyramid.views`` -- Views
"""
import os
import os.path
from pyramid.response import Response
from pyramid.view import view_config
_here = os.path.join(os.path.dirname(__file__), os.pardir)
_favicon = open(os.path.join(_here, 'static', 'favicon.ico'), 'rb').read()
_favicon_response = Response(content_type='image/x-icon', body=_favicon)
@view_config(route_name='favicon.ico')
def favicon_ico(context, request):
return _favicon_response
@view_config(route_name='home', renderer='home.mako')
def home(request):
def home(context, request):
return {}
@view_config(route_name='login', renderer='login.mako')
def login(request):
def login(context, request):
return {}
_robots = open(os.path.join(_here, 'static', 'robots.txt')).read()
_robots_response = Response(content_type='text/plain', body=_robots)
@view_config(route_name='robots.txt')
def robots_txt(context, request):
return _robots_response
def includeme(config):
config.add_route('home', '/')
config.add_route('favicon.ico', '/favicon.ico')
config.add_route('robots.txt', '/robots.txt')
config.add_route('login', '/login')
config.scan()