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.

dependencies:

from flask import request

function:

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