input-service/tester.py

24 lines
668 B
Python
Raw Normal View History

2020-04-27 12:42:46 +02:00
#!/usr/bin/env python3
import requests
import os.path
import json
from datetime import datetime
#URL = "https://birb.kmlabz.com/api/input/v1/sample"
#URL = "http://spitfire:30069/api/input/v1/sample"
URL = "http://localhost:5000/sample"
FILE = 'CommonStarling_100962.wav'
files = {
"file": (os.path.basename(FILE), open(FILE,'rb').read(), 'audio/wave', {'Content-length' : os.path.getsize(FILE)}),
"description" : (None, json.dumps({'date' : datetime.now().isoformat(), 'device_id' : '123'}), "application/json")
}
r = requests.post(URL,files=files)
print("Content: ", r.content)
print("Headers:", r.headers)
r.raise_for_status()
#print(r.json())