import csv
import sys
import requests


API_ENDPOINT = 'http://127.0.0.1:5000'

def usage():
    print('usage: python uploader.py <path_to_csv_file>')


def main(csv_path):
    with open(csv_path, 'r') as csv_f:
        data = csv.DictReader(csv_f, delimiter='\t')
        for cve in data:
            response = requests.post(
                API_ENDPOINT + "/postNewCve", 
                params={"cve_id": cve['CVE ID'], "cve_description": cve['Descr.']}
            )
            if response.status_code != 200:
                print("Error during post of {}".format(cve['CVE ID']))
            else:
                print("Successfully posted {}".format(cve['CVE ID']))

if __name__ == '__main__':
    if len(sys.argv) != 2:
        usage() 
        sys.exit(-1)
    main(sys.argv[1])
import csv
import sys
import requests


API_ENDPOINT = 'http://127.0.0.1:5000'

def usage():
    print('usage: python uploader.py <path_to_csv_file>')


def main(csv_path):
    with open(csv_path, 'r') as csv_f:
        data = csv.DictReader(csv_f, delimiter='\t')
        for cve in data:
            response = requests.post(
                API_ENDPOINT + "/postNewCve", 
                params={"cve_id": cve['CVE ID'], "cve_description": cve['Descr.']}
            )
            if response.status_code != 200:
                print("Error during post of {}".format(cve['CVE ID']))
            else:
                print("Successfully posted {}".format(cve['CVE ID']))

if __name__ == '__main__':
    if len(sys.argv) != 2:
        usage() 
        sys.exit(-1)
    main(sys.argv[1])