I have an API method deploy on my local server,
@app.post("/test/api")
async def method():
if incoming.request.url or domain == "this":
do some operation
else:
skip it
.....
return something
Now, Few people are using my API method, but is there any way I could track who is calling my api method and do specific extra operations to the once I specified who is calling my api.
How can I track the incoming domain name or ip or url of the people who are using my api method?
Note: Need a basic example on how to acheive it if you familiar with it
Is it something possible?
If you were using flask it could happen simply by getting remote_addr as below:
from flask import FLASK, request
@app.route('/test/api', methods=['POST']):
def method():
visitor_ip = request.remote_addr
In fastapi it should happen like this: request.client.host
any way you can work with headers in your code and get many details of your client
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With