I am facing an issue when I want to return the total visit count based on the counter that is already saved on Redis. I follow this documentation Flask limiter doc Here is the sample code:
from flask import Flask
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
app = Flask(__name__)
limiter = Limiter(
get_remote_address,
app=app,
storage_uri="redis://localhost:6379",
storage_options={"socket_connect_timeout": 30},
strategy="fixed-window", # or "moving-window"
)
@app.route("/slow")
@limiter.limit("10 per day")
def slow():
#my expect return is that it will return the total visit count based on counter that already store on redis
return "Visit count: "
what should i modified/add in the return of the slow()
function?
My expectation is that when I hit the /slow
endpoint, it will show the total number of the visit that get from Redis. I already tried to do the trick by making an independent variable counter, but the thing is that whenever the app stop, the counter also resets, that's why I'm trying to use Redis.