def generate_csv():
    boardsDesc = "The boards on 4chan you wish to gather from."
    boards = unpack_http_get_list(request.args.get('boards', None))
    boards = parameter_blacklist(boards, 'boards', boardsDesc)
    boards = parameters_must_be_inside_list(boards, BOARDS_4PLEBS, boardsDesc)
    print(boards)

    flaggerDesc = "The names of content flaggers to use. See {} for supported names.".format(
        url_for('content_flaggers'))
    flaggers = unpack_http_get_list(request.args.get('flaggers', None))
    flaggers = parameter_blacklist(flaggers, 'flaggers', flaggerDesc)
    flaggers = parameters_must_be_inside_list(flaggers,
                                              content_flagger_names(),
                                              flaggerDesc)
    print(flaggers)

    start_page = request.args.get('start_page', None)
    start_page = parameter_must_be_numeric(
        start_page, 'start_page',
        "The page of the imageboard's board to start gathering from.")
    print(start_page)

    stop_page = request.args.get('stop_page', None)
    stop_page = parameter_must_be_numeric(
        stop_page, 'stop_page',
        "The page of the imageboard's board to finish gathering from.")
    print(stop_page)

    stringInputStream = io.StringIO()

    posts = gather_range_with_boards(start=start_page,
                                     end=stop_page,
                                     boards=boards)

    CSVPostWriter.write_posts_to_stream(
        threads=posts,
        stream=stringInputStream,
        content_flaggers=content_flagger_names_to_ContentFlaggers(flaggers))
    # TODO: use their content flagger selections!

    output = make_response(stringInputStream.getvalue())
    print('wow10:', output)
    output.headers["Content-Disposition"] = "attachment; filename=export.csv"
    output.headers["Content-type"] = "text/csv"
    output.headers["charset"] = 'utf-8'

    return output
def _generate_csv_string_4plebs(boards: str, flaggers: str, start_page: str,
                                stop_page: str) -> str:
    boardsDesc = "The boards on 4chan you wish to gather from."
    boards = unpack_http_get_list(boards)
    boards = parameter_blacklist(boards, 'boards', boardsDesc)
    boards = parameters_must_be_inside_list(boards, BOARDS_4PLEBS, boardsDesc)
    print(boards)

    flaggerDesc = "The names of content flaggers to use. See {} for supported names.".format(
        url_for('content_flaggers'))
    flaggers = unpack_http_get_list(flaggers)
    flaggers = parameter_blacklist(flaggers, 'flaggers', flaggerDesc)
    flaggers = parameters_must_be_inside_list(flaggers,
                                              content_flagger_names(),
                                              flaggerDesc)
    print(flaggers)

    start_page = parameter_must_be_numeric(
        start_page, 'start_page',
        "The page of the imageboard's board to start gathering from.")
    print(start_page)

    stop_page = parameter_must_be_numeric(
        stop_page, 'stop_page',
        "The page of the imageboard's board to finish gathering from.")
    print(stop_page)

    stringInputStream = io.StringIO()

    posts = gather_range_with_boards(start=start_page,
                                     end=stop_page,
                                     boards=boards)

    CSVPostWriter.write_posts_to_stream(
        threads=posts,
        stream=stringInputStream,
        content_flaggers=content_flagger_names_to_ContentFlaggers(flaggers))
    # TODO: use their content flagger selections!

    return stringInputStream.getvalue()