如何返回 IP

2022-11-23
1
from flask import Flask, request, jsonify
2
3
app = Flask(__name__)
4
5
@app.route("/ip", methods=["GET"])
6
def ip():
7
"""返回访问 IP"""
8
return jsonify(origin=request.headers.get('X-Forwarded-For', request.remote_addr))