Skip to content

Instantly share code, notes, and snippets.

@ertugrulturan
Created June 5, 2020 16:30
Show Gist options
  • Save ertugrulturan/dbc5e66f22d955337877c6da56615132 to your computer and use it in GitHub Desktop.
Save ertugrulturan/dbc5e66f22d955337877c6da56615132 to your computer and use it in GitHub Desktop.
[PY] Testing firewall
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingMixIn
from requests import get, post
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
print(self.client_address[0]) # prints ip I think; start building from here
"""you can inspect the request, save its ip address maybe and then
make a POST request with the requests library and return the result"""
# if needed, same logic as above
def do_GET(self):
pass
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
address = (ip, port)
server = ThreadingHTTPServer(address, MyRequestHandler)
server.server_forever()
@ertugrulturan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment