改成类似这样
- def GetClientIp():
- from flask import request
- ipaddr = request.remote_addr.replace('::ffff:','')
- if request.headers['X-Forwarded-For'] is not None:
- ipaddr = request.headers['X-Forwarded-For']
- elif request.headers['X-Real-IP'] is not None:
- ipaddr = request.headers['X-Real-IP']
- if not check_ip(ipaddr): return '~\~_IP~\~]~@'
- return ipaddr
复制代码 |