Python Forum
appending variabl a URL for requests.post step
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
appending variabl a URL for requests.post step
#1
I use one of my RPis for monitoring my fridge temp. I currently have LEDs lit to indicate a good or bad condition. I also get a push notification when the monitoring service starts (cronjob @reboot). The code is a loop that checks the temps every 5 minutes and will send me a push notification (using requests.post and Android apps Join and Tasker). Using Tasker, I can have my phone respond to incoming messages (not just text messages - think pushes). I want the pi to attach a variable to the base of the URL so I can catch the event, where Tasker can alert me, showing the issue.

import requests


base = https://autoremotejoaomgcd.appspot.com/sendmessagekey=goo.gl:lonstrinofcharactersthatyoudonotneedforthis&message=

alert = overtempfreezer

r = requests.post("base + alert")
So the "base" variable will always be that. Never changes. It has been edited for privacy. At the end is "&message=" where the next characters would be the "alert" variable. I am hoping to combine the ougoing requests.post to be "https://autoremotejoaomgcd.appspot.com/sendmessagekey=goo.gl:lonstrinofcharactersthatyoudonotneedforthis&message=overtempfreezer"

Why not just combine them? There are other conditions that could be populated to be the "alert" variable, such as alert = overtempfridge, or alert = freezerdooropen.

How do I append the "alert" variable to the "base" and send it with a requests.post?
Reply


Messages In This Thread
appending variabl a URL for requests.post step - by duckredbeard - Sep-04-2020, 05:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't log in with requests post LilDog 2 6,085 Mar-11-2019, 08:16 AM
Last Post: yourv3nom
  Step -1 Upandon 2 3,082 Feb-27-2018, 06:02 AM
Last Post: Upandon
  No route to host error when using requests.post in python on raspberry pi mariummalik22 0 4,082 Jan-06-2018, 08:34 PM
Last Post: mariummalik22

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020