How to run my python script only when new response form requests.get is received? | Community
Skip to main content
Answered

How to run my python script only when new response form requests.get is received?

  • February 22, 2022
  • 4 replies
  • 382 views

I wrote a application with the following logic:

 

1) Fetch Data with API2) Preprocess the Data3) Start topic modeling4) Create report and include data5) Handle final pdf report (send, show in browser ...)

 

Now i only want to start this 5 steps when a new response is received. 

 

So far the script works, but only processes the response when i manually run the script on my system.

 

I also tried using pm2 for running the script like a daemon thread. However, even the script (process) runs forever, it loops over the 5 steps over and over again for the same response. But i want to stop the 5 steps after every individual response.

 

My desired architecture should look like that:

 

if new response:    1) Fetch Data with API    2) Preprocess the Data    3) Start topic modeling    4) Create report and include data    5) Handle final pdf report (send, show in browser ...)else:    wait for new reponse …

 

Any help is appreciated.

 

EDIT in title* form not form

Best answer by pgphi

Thank you @Liz and @mathio.

I used the Webhook API and set up an endpoint with flask (python web-framework). This worked. @mathio i also will look into the after query approach - thank you both!

View original

4 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • February 24, 2022

@mathio do you happen to know an answer to this? :grinning:


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • February 24, 2022

@Liz sorry I do not know Python :) 

@pgphi maybe you could expose your script on a URL and use Webhooks API? Or you could store the last processed response and use the after query parameter when retrieving responses via API.


  • Author
  • Explorer
  • 1 reply
  • Answer
  • February 24, 2022

Thank you @Liz and @mathio.

I used the Webhook API and set up an endpoint with flask (python web-framework). This worked. @mathio i also will look into the after query approach - thank you both!


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • February 25, 2022

Glad to hear that worked, @pgphi !!


Reply