Jul 122012

This is a simple function to get remote user’s IP address using Flask’s request_object. It is very simple and takes a lot of tweaks, like reading also the X-Forwarded-For field from received header for users who use proxies.


from flask import request


def get_ip():
  # get creative here!
  return request.remote_addr