I'm trying to implement the get_my_ip() method from flask. I'm getting an unresolved reference despite importing the relevant packages. I found solutions for similar issues that say that I have folder named 'app', which causes the problem, but I couldn't find such folder.
The code:
from flask import request
from flask import jsonify
@app.route("/get_my_ip", methods=["GET"])
def get_my_ip():
return jsonify({'ip': request.remote_addr}), 200
The function is called as follows:
with open('file.txt, 'a') as f:
f.write(f'ip: {get_my_ip()}')
Thanks.