def task_pcap_create():
    """Endpoint for network/pcap analysis task."""
    if 'pcap' not in request.files:
        # no pcap file
        res = ErrorAPIResponse(2010).to_dict()
        return jsonify(res), 400

    pcap_file = request.files['pcap']

    if pcap_file.filename == '':
        # noname file
        res = ErrorAPIResponse(2011).to_dict()
        return jsonify(res), 400

    # get pretty print parameter
    pretty = False
    if 'pretty' in request.form:
        pretty = request.form['pretty']
        if pretty not in ('true', 'false'):
            res = ErrorAPIResponse(2000).to_dict()
            return jsonify(res), 400

    task_id = uuid()

    # prepare directory and save pcap
    os.mkdir(f'{storage_path}/{task_id}')
    pcap_path = f'{storage_path}/{task_id}/{pcap_file.filename}'
    pcap_file.save(pcap_path)

    # run pcap analysis
    args = (pcap_path,)
    kwargs = {'pretty': pretty}
    tasks.pcap_analysis.apply_async(args, kwargs, task_id=task_id)

    res = {
        'task_id': task_id
    }
    return jsonify(res)
Endpoint for network/pcap analysis task.
lisa/web_api/routes.py