Microsoft Excel (CSV)

Webhook

$ pip3 install Flask
webhook.py
from flask import Flask, request, jsonify, make_response
import json, os, csv


app = Flask(__name__)

@app.route('/data', methods = ['POST', 'GET'])
def data(): 
    data = request.json
    data_string = json.dumps(data)
    data_json = json.loads(data_string)
    
    #example data
    header = ["tax", "date","invoice_to"] 
    tax = data_json['tax']
    date = data_json['date']
    invoice_to = data_json['invoice_to']
    
    fieldnames = ['tax', 'date', 'invoice_to']
    filename = '/path/to/folder/invoices.csv'

    with open(filename, 'a', newline='\n') as csvUser:
        # reG is now a dictionary, as required by writerow.
        reG = {'tax': tax, 'date': date, 'invoice_to': invoice_to}
        writer = csv.DictWriter(csvUser, fieldnames=fieldnames)

        # if it's an empty file, write the header
        if os.stat(filename).st_size == 0:
            writer.writeheader()
            
        writer.writerow(reG)

    csvUser.close()

    return make_response("",200)

if __name__ == "__main__":
    app.run(host = '127.0.0.1', port='3000', debug=True)
python3 webhook.py

#running in background
nohup python3 webhook.py > captodocs.log 2>&1 &

Última actualización