title: List of query params with Flask request.args
body: <p>I am trying to pass comma separated query parameters to a Flask endpoint.</p>
  <p>An example URI would be:</p>
  <p><code>localhost:3031/someresource#?status=1001,1002,1003</code></p>
  <p>Looking at the return of <code>request.args</code> or <code>request.args.getlist('status')</code> I see that I only get a string.</p>
  <pre><code>ipdb&gt; pp request.args
  ImmutableMultiDict([('status', '1001,1002,1003')])
  ipdb&gt; request.args.getlist('status')
  ['1001,1002,1003']
  </code></pre>
  <p>I know I can split the string by comma but that feels hacky. Is there a more idiomatic way to handle this in Flask? Or are my query params wrong format?</p>
  <p><strong>Solution</strong><br />
  Since Flask does not directly support comma separated query params, I put this in in my base controller to support comma-separated or duplicate query params on all endpoints.</p>
  <pre><code>request_data = {}
  params = request.args.getlist('status') or request.form.getlist('status')
  if len(params) == 1 and ',' in params[0]:
      request_data['status'] = comma_separated_params_to_list(params[0])})
  else:
      request_data['status'] = params
  </code></pre>
  <pre><code>def comma_separated_params_to_list(param):
      result = []
      for val in param.split(','):
          if val:
              result.append(val)
      return result
  </code></pre>