Reputation: 807
I am using a web service that will send a url callback when a particular external event happens (that service is monitoring it 24-7)
I need to have a python script running (locally on my own computer) and waiting (possibly just looping) to receive that callback and then do something with the data.
How do I do this? Do I need to have a webserver running? Where do I look for the data? I am pretty experienced with python, but not much in the use of HTTP and other web related things.
I have looked at other stackoverflow posts but they all seem to presume some prior knowledge.... I need the basics!
Upvotes: 0
Views: 1859
Reputation: 12795
Here is a simple server using Bottle Microframework .
from bottle import Bottle, run, route, request
app = Bottle()
@app.route('/listener')
def my_listener():
data = request.query.your_data
#do_something_with_data(data)
return data
run(app, host="0.0.0.0", port=8080)
You can send data to server requesting http://sever_ip:8080/listener?your_data=some_data
Upvotes: 2
Reputation: 5588
Look into setting up a Flask server that will run in the background and listen for the callback request
Upvotes: 0