Python Flask get IP of user
Question:
I am trying to log the IP address of a user whenever they submit a form so I can prevent them from submitting the same form twice, how can I achieve this?
(I am using flask and a replit template)
Answers:
With Flask, the request
variable has a remote_addr
that contains the IP address of the origin.
from flask import request
@app.route("/submit", methods=["GET"])
def submit():
const userIP = request.remote_addr; # This is the IP address of the request.
I am trying to log the IP address of a user whenever they submit a form so I can prevent them from submitting the same form twice, how can I achieve this?
(I am using flask and a replit template)
With Flask, the request
variable has a remote_addr
that contains the IP address of the origin.
from flask import request
@app.route("/submit", methods=["GET"])
def submit():
const userIP = request.remote_addr; # This is the IP address of the request.