Given a tag regex and single run, return ScalarEvents.

    This route takes 2 GET params:
    run: A run string to find tags for.
    tag: A string that is a regex used to find matching tags.
    The response is a JSON object:
    {
      // Whether the regular expression is valid. Also false if empty.
      regexValid: boolean,

      // An object mapping tag name to a list of ScalarEvents.
      payload: Object<string, ScalarEvent[]>,
    }

def scalars_route(self, request):
    """Given a tag regex and single run, return ScalarEvents.

    This route takes 2 GET params:
    run: A run string to find tags for.
    tag: A string that is a regex used to find matching tags.
    The response is a JSON object:
    {
      // Whether the regular expression is valid. Also false if empty.
      regexValid: boolean,

      // An object mapping tag name to a list of ScalarEvents.
      payload: Object<string, ScalarEvent[]>,
    }
    """
    # TODO: return HTTP status code for malformed requests
    tag_regex_string = request.args.get('tag')
    run = request.args.get('run')
    mime_type = 'application/json'

    try:
      body = self.scalars_impl(run, tag_regex_string)
    except ValueError as e:
      return http_util.Respond(
          request=request,
          content=str(e),
          content_type='text/plain',
          code=500)

    # Produce the response.
    return http_util.Respond(request, body, mime_type)