1

I am setting python local server using python -m SimpleHTTPServer, I made that server publicly available using ngrock and have some public IP address like http://2ee94---.ngrok.io. Now I am making the request to the public IP address. I want to get IP address from request. But I am getting the only status in the terminal. How to get details (IP address of client) of the request.

HTTP Requests                                                                   
-------------                                                                   

GET  /                         200 OK                                           
GET  /                         200 OK  
Akshay Bande
  • 2,491
  • 2
  • 12
  • 29

1 Answers1

0

I got it done after setting up my own handler class,

import SimpleHTTPServer
import SocketServer


class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def handle_one_request(self):
        print(self.client_address[0])
        return SimpleHTTPServer.SimpleHTTPRequestHandler.handle_one_request(self)

httpd = SocketServer.TCPServer(("", 8080), MyHandler)

while True:
    httpd.handle_request()
Akshay Bande
  • 2,491
  • 2
  • 12
  • 29