# How to send computing results?

58 views
Thanks again for all your help before.

I want to realise transport channel between WooDEM and my program on http server. I would like to send result of calculations (namely the coordinates of the figures at each time point) by POST request on my server and process them.

From documentation I don't understand clearly from which part (module, class or function...) I can send requests with coordinates. Can you help me solve my problem?

Thanks a lot!

answered Jun 1, 2017 by (48,950 points)
selected Jun 2, 2017

Hi Roman,

the easiest approach is to define python function which will do the POST request, and call it periodically from engines, something like this:

S.engines=woo.dem.DemField.minimalEngines(...)+[
woo.core.PyRunner(1000,"doPostData(S)") # run every 1000 steps
]

def doPostData(S):
# You need http://docs.python-requests.org/ package for this, easy to install through
# either APT (sudo apt install python3-requests) or pip (pip3 install requests)
import json, requests
# let's send all node's coordinates
# we encode the list of tuples as JSON (but can be anything the other side can accept)
# and put into a dictionary as "coords", so that other things can be added easily
# finito