yps_baslat6.py 624 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/python3
  2. import socket
  3. from http.server import HTTPServer, SimpleHTTPRequestHandler
  4. class MyHandler(SimpleHTTPRequestHandler):
  5. def do_GET(self):
  6. if self.path == '/ip':
  7. self.send_response(200)
  8. self.send_header('Content-type', 'text/html')
  9. self.end_headers()
  10. self.wfile.write('ip adresiniz %s' % self.client_address[0])
  11. return
  12. else:
  13. return SimpleHTTPRequestHandler.do_GET(self)
  14. class HTTPServerV6(HTTPServer):
  15. address_family = socket.AF_INET6
  16. def main():
  17. server = HTTPServerV6(('::', 8000), MyHandler)
  18. server.serve_forever()
  19. if __name__ == '__main__':
  20. main()