Forums

Launch/Run a PA script from IFTTT/DO button

Newbie here so apologies if this has already been answered somewhere.

I want PythonAnywhere to run a Python script with the press of the 'DO Button' app on my iPhone. I think it's possible to send GET or POST http requests via the Maker channel on the 'DO Button' side, so it comes down to whether PA can pick that up and run a python script.

Possible?

Thx in advance.

That's pretty easy.

Go to the web tab. Create a Flask web app. If you look in the files it's pretty obvious what you have to do. (It's worthwhile learning Flask, as you'll quickly discover 101 things that made better by adding a simple webhook.)

Great. Looking into Flask and it seems to be what I need. Thanks!

Hi, guys. I have the same problem. Is it possible to contact you in private? Ojsaito, did you solve the problem? If yes, how? I really need this!

Edit: if someone sees this post and know the answer, please reply. Thanks

Hi bluebuffalo,

It's pretty easy to trigger a script via IFTTT.

Go to the web app tab on PythonAnywhere. Create a new flask app. Put your script inside the flask app:

So:

@app.route("/myscript")
def myscript():
    # Put your script here
    return "Hello World!"

And then use the IFTTT Maker channel to point to http://bluebuffalo.pythonanywhere.com/myscript

And that's literally it. I control half my house via IFTTT, Flask and PythonAnywhere

Thanks

Hi rcs1000, thank you very much! I even don't know how but I have done something similar today! I used a function and configured IFTTT webhooks with POST request. I think I'm going to do things right.

But... I found something wrong... I tried to run my script just for test and it gives me an error. I searched on Google and I found that PythonAnywhere blocks external sites with a proxy or something like that. I visited a page (here http://help.pythonanywhere.com/pages/RequestingWhitelistAdditions/ ) that suggested me to ask for the input of my site (made with Blogger) in their whitelist. I sent them a feedback from the top link. Hope they'll add the site.

However this is another problem xD. I think I'm going to write a post about ifTTT and PythonAnywhere and paste the link here.

Thanks for your fast reply!!

They block external stuff because people have used PythonAnywhere to launch denial of service attacks. I think you can get a paid account for a couple of dollars a month if you just want unrestricted external access.

Or you can ask them to whitelist the site you're trying to reach.

Yes, I read. For the thing I have to do (simple thing with rss feed) I would spend nothing

Unfortunately we only add endpoints that have official api documentation (intended to be accessed publicly and programmatically) to the whitelist for free users.

I think Blogger has one, I'm optimist because I saw another (3) site mysite.blogspot.com.

Ah- we will have to clean up our whitelist then! Our whitelist policy has definitely evolved over time, and these may have been from 4+yrs ago when installing some packages over PYPI hits external urls (it doesn't do so anymore).

:( ok. Thanks anyway