Python Forum

Full Version: Detect http request on my ip
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to write a python script that detects when a http request is made on the IP address of my home network. I have a dynamic DNS set up so that I can access my little home server any time.
I want to execute code after the http request is made and make check on the payload if it is a POST.

I'm new but not new at networking stuff so I don't know where to start. I always had no problems making http requests and thought that it would be easy to detect them.

Can anyone guide me in the right direction?
Well, think about it: when you make an HTTP request, you do so to a server, don't you? So, you need to be running an HTTP server that will listen for requests and do what you want with them. There are a number of web frameworks that allow you to write web applications that handle HTTP requests and return responses - Flask, Django, Bottle, CherryPy are some of them. These often have a server you can use while developing, but may not be recommended for production use. In those cases, you'll want to run your application using a WSGI server (for example, Gunicorn is one available for UNIX, but there are others).