我有以下路线:
http://localhost:5000/example-poll-key/close
<participant_key>URL
<poll_key>/close
<participant_key>
我错过了match_compare_key:
match_compare_key
(True, -2, [(0, -6), (1, 200)])
/<poll_key>/close:(True, -2, [(1, 100), (0, -5)])
/<poll_key>/<participant_key>:(True, -2, [(1, 100), (1, 100)])
这意味着的static优先级高于其他优先级,并且close优先级高于<participant_key>。
static
close
例:
from flask import Flask app = Flask(__name__) app.add_url_rule('/<poll_key>/close', 'close', lambda **kwargs: 'close\t' + str(kwargs)) app.add_url_rule('/<poll_key>/<participant_key>', 'p_key', lambda **kwargs: 'p_key\t' + str(kwargs)) client = app.test_client() print client.get('/example-poll-key/close').data print client.get('/example-poll-key/example-participant-key').data
输出:
close {'poll_key': u'example-poll-key'} p_key {'participant_key': u'example-participant-key', 'poll_key': u'example-poll-key'}
看起来这是正确的行为。