URL, int, , int. API- , , , : /answers/1;2;3. .
from werkzeug.routing import BaseConverter
class IntListConverter(BaseConverter):
"""Match ints separated with ';'."""
regex = r'\d+(?:;\d+)*;?'
def to_python(self, value):
return [int(x) for x in value.split(';')]
def to_url(self, value):
return ';'.join(str(x) for x in value)
app = Flask(__name__)
app.url_map.converters['int_list'] = IntListConverter
@app.route('/user/<int_list:ids>')
def process_user(ids):
for id in ids:
...