Skip to content
← Back to Community
Client IP in Flask.
Profile icon
pumpedupkicks

According to the Flask documentation, you should be able to see the client's IP through request.remote_addr and request.access_route. On replit this seems to return 127.0.0.1 and 35.191.x.xxx which is a Google Cloud IP after I looked it up.

I am looking for the ability to send a Json post request to the server, who will in turn send one back to the client (for this example it's just {key: value})

Any ideas what I'm doing wrong, or other I can achieve this functionality inside python?

from flask import Flask from flask import request app = Flask('') @app.route("/ping", methods=['POST']) def ping(): data = request.get_json() print("Got a request!") print(data) print(request.access_route) print(request.remote_addr) reply = requests.post(request.remote_addr, data = {'key':'value'}) print(reply)
Voters
Profile icon
PythonicWarrior
Profile icon
pumpedupkicks
Comments
hotnewtop
Profile icon
xfinnbar

Replit proxies connections through that 35.191.x.xxx, so this isn't possible. This is to prevent IP logging I believe. What you can do hovever is use a websocket server for two-way communication if you want.

Profile icon
ch1ck3n

@xfinnbar ohh that's why i had trouble with the IP stuff too