Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9288183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:51:34+00:00 2026-06-18T19:51:34+00:00

In my pyramid app, I have several static html files under tutorial/tutorial/pages/name.html (for example).

  • 0

In my pyramid app, I have several static html files under tutorial/tutorial/pages/name.html (for example). How can I write a view callable for this? Would this work?

     @view_config(renderer='view_page')
     def view_page(request):
         return {} # no values have to be passed to the template

then in the init.py file

config.add_route('view_page', 'tutorial:pages/{name}.html')

What do I need to put in the def view_page(request) function to call that name.html file specifically and then display its content?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:51:35+00:00Added an answer on June 18, 2026 at 7:51 pm

    Pyramid’s static_view is a view capable of serving files from a directory. The part you really haven’t explained is what the URLs are like for these static pages. For example, if they are all under a common prefix, you could use static_view (option 1). If they are not, then you have to create a view per page and serve it up directly (option 2).

    option 1

    url:

    /foo/bar.html
    /foo/baz/boo.html
    

    static view:

    config.add_static_view('/foo', 'tutorial:pages')
    

    tutorial/pages hierarchy:

    tutorial/pages/bar.html
    tutorial/pages/baz/boo.html
    

    add_static_view is effectively like calling add_route('foo', '/foo/*subpath'), and it serves up the subpath relative to tutorial:pages.

    option 2

    config.add_route('foo', '/foo')
    config.add_route('bar', '/foo/bar')
    
    @view_config(route_name='foo', renderer='tutorial:pages/foo.html.mako')
    @view_config(route_name='bar', renderer='tutorial:pages/bar.html.mako')
    def static_view(request):
        return {}
    

    Notice the .mako suffix to invoke the mako renderer. There is no .html renderer by default, but you could make one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom 404 view defined in my Pyramid app: @view_config(context=HTTPNotFound, renderer='404.pt') def
In a pyramid application, I defined a static view for serving css/js files and
I am using latest Pyramid to build a web app. Somehow we have started
I have a Python 2 Pyramid web app using SQLAlchemy to talk to a
I have a Pyramid app and apache with mod_wsgi and I'm trying to make
I have a Pyramid app that uses Chameleon for its templates. I would like
I have deployed a Pyramid app using mod_wsgi. I have setup the python path
So I have a pyramid traversal app and I'd like to be able to
Right now I have a pyramid (python) app with a home page that is
I have a very simple Pyramid app (my first one) and I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.