I have added HTTP POST to rtgd.py using a similar approach to that taken in the weeWX RESTful API in restx.py. It seems to work well. The php I am using is:
<?php // we are only interested in HTTP POST if($_SERVER['REQUEST_METHOD'] == 'POST') { // get the data $data = file_get_contents("php://input"); // write the data to file file_put_contents("json/gauge-data.txt", $data); // send something back indicating success echo "success"; } ?> If OK with you Alec I have mentioned you in the comments as the source of the idea and referenced your repo. I will publish 0.2.11 later today. Gary On Wednesday, 22 March 2017 01:40:17 UTC+10, Alec Bennett wrote: > > > > Just wondering if there was any particular reason you used a GET rather > than a POST? I think the code to support passing the data via GET is a > little simpler than a POST but since GET includes all of the data in the > URL my nginx access log is getting hammered. I estimate about 55Mb per day. > > > Very interesting, I hadn't considered that. I'll switch to POST later > today. > > > > > > > > Gary > > On Tuesday, 21 March 2017 13:09:56 UTC+10, gjr80 wrote: >> >> Good work, I must admit I had been stuck in the 'file transfer' paradigm >> rather than 'data transfer' and whilst I have had loop based RSYNC working >> on my LAN there was too much contention for my liking. I will have have a >> look at this and see how your approach works for me. >> >> Gary >> >> On Tuesday, 21 March 2017 04:41:49 UTC+10, Alec Bennett wrote: >>> >>> The short answer to your question is no, nothing like that exists at the >>>> moment. If you have your web server (or process that wil use >>>> gauge-data.txt) on your weeWX machine then it is a simple matter for the >>>> generated file to be saved wherever you want, but if you need to transfer >>>> the file in near realtime to another machine then no that capability does >>>> not exist at the moment. >>>> >>> >>> I added the ability to post live_data.json to a remote webserver, if >>> anyone needs the ability, it's here: >>> >>> https://github.com/wrybread/weewx-realtime_gauge-data >>> >>> It works by posting all the data it writes to live_data.json to a PHP >>> script on a remote webserver using a GET statement. Note the PHP script >>> here, that receives the data: >>> >>> >>> https://github.com/wrybread/weewx-realtime_gauge-data/tree/master/PHP%20Script >>> >>> If anyone wants me to convert it to Python for consistency, let me know. >>> >>> To use, set the following value in the RealtimeGaugeData section of your >>> weewx config file: >>> >>> remote_server_url = >>> http://yourwebsite.com/path_to/receive_conditions.php >>> >>> It's my first time posting a fork to github, so please let me know if I >>> did anything dumb. And let me know if anyone wants me to change anything. >>> >>> -- > You received this message because you are subscribed to a topic in the > Google Groups "weewx-user" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/weewx-user/ws7u2itvJMw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > weewx-user+...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.