Reputation: 11533
I have a beginner question with URL Dispatch or Traversal. What I am trying to do, is use Mako renderer to render my views. So I have this folder /includes/ where all the html and css and javascript is. Here is my Pyramid main code:
from pyramid.config import Configurator
def main(global_config, **settings):
config = Configurator(settings=settings)
config.add_static_view('includes', 'includes', cache_max_age=3600)
config.add_renderer(".html", "pyramid.mako_templating.renderer_factory")
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
And these are my views:
@view_config(route_name='home', renderer='index.html')
def my_view(request):
return {'name':'Netherdrake'}
@view_config(name = 'login', renderer='login.html')
def login(request):
return {'name':'Netherdrake'}
The problem is, when I access ip:port/login the site works fine, but when I try ip:port/login/ the css, javascript and images don't work. The reason is, my absolute paths become invalid.
And here is my login.html snippet (which is mako template really) while login without /:
<link href="includes/css/twitter/bootstrap.css" rel="stylesheet">
<link href="includes/css/base.css" rel="stylesheet">
<link href="includes/css/twitter/responsive.css" rel="stylesheet">
<link href="includes/css/jquery-ui-1.8.23.custom.css" rel="stylesheet">
<script src="includes/js/plugins/modernizr.custom.32549.js"></script>
And here it is while Im going for login/ path (site is broken in this case, no css, images, js...):
<link href="includes/css/twitter/bootstrap.css" rel="stylesheet">
<link href="includes/css/base.css" rel="stylesheet">
<link href="includes/css/twitter/responsive.css" rel="stylesheet">
<link href="includes/css/jquery-ui-1.8.23.custom.css" rel="stylesheet">
<script src="includes/js/plugins/modernizr.custom.32549.js"></script>
The login.html is in /includes too.
How can I fix this, and make it work under both paths, with and without slash? I tried traveral and url dispatch, and problem is same in both.
Upvotes: 1
Views: 344