········endpoint, kwargs = urls.match()
········if endpoint == 'index':
············response = werkzeug.Response("You got the index.")
········elif endpoint == 'ask':
············questions = dict(
················Galahad='What is your favorite color?',
················Robin='What is the capital of Assyria?',
················Arthur='What is the air-speed velocity
························of an unladen swallow?')
············response = werkzeug.Response(questions[kwargs['person']])
········else:
············response = werkzeug.Response("Other: {other}".format(**kwargs))
····except (KeyboardInterrupt, SystemExit):
········raise
····except:
········response = werkzeug.Response(
········'You may not have gone where you intended to go,\n'
········'but I think you have ended up where you needed to be.',
········status=404
········)
····return response
Для того чтобы протестировать этот фрагмент, снова используйте класс werkzeug.Client:
>>> client = werkzeug.Client(send_to_endpoint, response_wrapper=werkzeug.Response)
>>> print(client.get("/"). data.decode())
You got the index.
>>>
>>> print(client.get("Arthur"). data.decode())
What is the air-speed velocity of an unladen swallow?
>>>
>>> print(client.get("42"). data.decode())