Ask coding questions

← Back to all posts
Client IP in Flask.
pumpedupkicks (0)

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 and 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!")
  reply =, data = {'key':'value'})
xfinnbar (21)

Replit proxies connections through that, 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.

ch1ck3n (1618)

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