examples/manual_put_model.py

23 lines
631 B
Python

#!/usr/bin/env python3
import requests
import os.path
import json
URL = "http://10.105.115.192/model"
FILE = 'Prototype2500SVM'
files = {
"modelFile": (os.path.basename(FILE), open(FILE,'rb').read(), 'application/octet-stream', {'Content-length' : os.path.getsize(FILE)}),
"meansFile": (os.path.basename(FILE + "MEANS"), open(FILE + "MEANS",'rb').read(), 'application/octet-stream', {'Content-length' : os.path.getsize(FILE + "MEANS")}),
"info" : (None, json.dumps({'type' : 'svm'}), "application/json")
}
r = requests.post(URL,files=files)
print("Content: ", r.content)
print("Headers:", r.headers)
r.raise_for_status()