私はトルネードで遊んできましたが、とてもうまく見えないコードを書いています。トルネードのURLクエリパラメータ
例としてレシピを保存するアプリを作成しています。これらは私のハンドラです:
handlers = [
(r"/recipes/", RecipeHandler),
(r"/recipes", RecipeSearchHandler), #so query params can be used to search
]
この本を書くことに私を導く:
class RecipeHandler(RequestHandler):
def get(self):
self.render('recipes/index.html')
class RecipeSearchHandler(RequestHandler):
def get(self):
try:
name = self.get_argument('name', True)
self.write(name)
# will do some searching
except AssertionError:
self.write("no params")
# will probably redirect to /recipes/
は除くのtry /なしでこれらのURLにアプローチするより良い方法はありますか?/recipesと/ recipes /は同じものを表示したいのに対し、/ recipes?name = somethingは検索を行い、理想的には別のハンドラにするのが好きです。
1を参照してください。しかし、このURLパターンは、私がこのような検索をしたい場合、もっと多くのパラメータを含めるように拡張されていますか?/ recipes?ingredients = chicken&style = indian – colinjwebb