2

I am writing a python program for google appengine using jinja2 as my template engine. I would like to have a single handler for a multitude of posts and some of them having pretty different URLs but all having the same base.

Is is possible for me to have a URL handler like this:

app = webapp2.WSGIApplication([('/post/([.*]+)/([.*]+)/([.*]+)/([.*]+)', PostPage), ], debug=True)

And yet have it accept URLs that don't fill every one of those addtitions like having a URL:

/post/1234/some-title

If not is there some way that I can change it so that one handler can take URLs for many pages?

1 Answer 1

3

If you don't need (as parameters for the handler) the parts of the path that are after the /post/{param1} you can simple write app = webapp2.WSGIApplication([('/post/(.*)/.*', PostPage) and the handler will except everything in the form of /post/{id}/.*

Sign up to request clarification or add additional context in comments.

2 Comments

so it is giving me a error: TypeError: get() takes exactly 3 arguments (2 given) any idea why that is?
@clifgray if you have two params in your handler then the code should be: app = webapp2.WSGIApplication([('/post/(.*)/(.*)/.*', PostPage)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.