add /favicon.ico and /robots.txt views
This commit is contained in:
parent
ce16a1cf6f
commit
925cd30b96
3 changed files with 29 additions and 2 deletions
BIN
edbob/pyramid/static/favicon.ico
Normal file
BIN
edbob/pyramid/static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
2
edbob/pyramid/static/robots.txt
Normal file
2
edbob/pyramid/static/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow: /
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue