How to use HTM Engine python

Dear all,

I am trying to use the but I am facing issues when I want to POST data.

I was able to create a model with this command: curl http://localhost:8080/cpu -X PUT -d ‘{“min”:0, “max”:100}’ -i

But when I send a POST request like this it fails (500: internal server error): curl http://localhost:8080/cpu -X POST -d 0.35 1470301465

Anyone knows how to send POST requests to the webapp?

Thank you,
Best regards,
José Santos

What is the error in the server logs? I think it’s because you’re not sending data in the right format. From your curl command, you need to put quotes around the string data you’re sending. Also, it might need to be JSON? I can’t remember.

Hi rhyolight,

I solved the issue by sending it as on the example of the skeleton engine.

On my script, I just do:

echo $values | $curl where:

$values = 0.346 14789232
$curl = “curl -X POST -d @-”

But I would like to know exactly how can I send the values in JSON format.

Best regards,
José Santos

Here is the code I used in the HTM Engine Traffic Tutorial. It is a JavaScript HTTP client for the HTM Engine. Here is the code that POSTs data to the engine:

Look through that file for other examples of constructing HTTP requests for HTM Engine.

Ok. Thank you for the help.

htmengine doesn’t natively have an interface to receive data in json format – json is not suited for streaming data. Instead, it implements a graphite-inspired TCP interface for accepting metric data – see for more information.

htmengine alone also does not have a web server. skeleton-htmengine-app does, but is only a minimal viable example of building an app using htmengine. in skeleton-htmengine-app does implement a HTTP interface to receive metric data via POST, and can be modified to accept json starting around

Get Outlook for Android

1 Like

I should also add that in your original curl command, if you surround the metric value and timestamp with quotes, e.g. -d “0.35 1470301465”, it should work. It’s failing because curl is interpreting the timestamp as a separate argument.

Get Outlook for Android

Thank you @Austin_Marshall it worked.

Best regards,
José Santos