Skip to content

Instantly share code, notes, and snippets.

@tnuki10
Last active December 17, 2015 18:39
Show Gist options
  • Save tnuki10/5654527 to your computer and use it in GitHub Desktop.
Save tnuki10/5654527 to your computer and use it in GitHub Desktop.
webapp2でThe URL templateを使ってみるサンプル。 動かしていないので、これで動くかどうかは分かりませんが、こんな感じで使えそう。
class aaaa(webapp2.handler):
def get(self, path1, path2=None, path3=None)
if path2 is None:
path2='defult'
if path3 is None:
path3='defult'
app = webapp2.WSGIApplication([
webapp2.Route(r'/<path1>/<path2>/<path3>', handler=aaaa),
webapp2.Route(r'/<path1>/<path2>', handler=aaaa),
webapp2.Route(r'/<path1>', handler=aaaa),
])
@curious-eyes
Copy link

動きました!Route.match( )の戻り値 kwargs に入ってきてくれるので、
dispatcher で捕捉できそうです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment