예제 #1
0
def hello2():
    if request.method == 'POST':
        f = request.files['file']
        f.save(f.filename)
        filename, ext = f.filename.split('.')
        filename = filename + '_'
        print('here')
        print(filename, ext)
        with open(f.filename) as json_data:
            trans = json.load(json_data)
            results = transaction_reporting(**trans)
            if results:
                keys = results[0].keys()
                with open(filename + '.csv', 'w') as csv_file:
                    c = csv.writer(csv_file)
                    c.writerow(keys)
                    for result in results:
                        c.writerow(result.values())

        return send_from_directory(directory='.', filename=filename + '.csv')
        # return 'complete'

    else:
        return render_template('trans.html', domain=DOMAIN)
예제 #2
0
from lib.execute import daily_reporting, transaction_reporting
import json
import csv

with open('trans.json') as json_data:
    trans = json.load(json_data)
    results = transaction_reporting(**trans)
    # print(results)
    if results:
        keys = results[0].keys()
        with open('trans.csv', 'w') as csv_file:
            c = csv.writer(csv_file)
            c.writerow(keys)
            for result in results:
                c.writerow(result.values())

# with open('daily.json') as json_data:
#     daily = json.load(json_data)
#     results = daily_reporting(**daily)
#     if results:
#         keys = results[0].keys()
#         with open('daily.csv', 'w') as csv_file:
#             c = csv.writer(csv_file)
#             c.writerow(keys)
#             for result in results:
#                 c.writerow(result.values())
예제 #3
0
def test2():
    if request.method == 'POST':
        input_data = request.get_json()
        results = transaction_reporting(**input_data)
        return jsonify(results)