get("/", dependencies=[Depends(RateLimiter(times=2, seconds=5))]) async def index(): return {"msg": "Hello World"} if __name__ == "__main__": uvicorn.run("main:app", debug=True, reload=True)UsageThere are some config in FastAPILimiter.init....
According to the github repo README.md I have to use @asynccontextmanager async def lifespan(_: FastAPI): redis_connection = redis.from_url("redis://localhost:6379", encoding="utf8") await FastAPILimiter.init(redis_connection) yield awai...
A request rate limiter for fastapi. Contribute to long2ice/fastapi-limiter development by creating an account on GitHub.
the 'on_startup' function does't be called on IIS,so the "await FastAPILimiter.init(cache)"also does't be called my solution: try to call FastAPILimiter.init on server starting, FastAPILimiter.redis = cache FastAPILimiter.prefix = "fastapi-limiter" FastAPILimiter.identifier = default_identifi...
await FastAPILimiter.init(redis) redis_connection = redis.from_url("redis://localhost", encoding="utf-8", decode_responses=True) await FastAPILimiter.init(redis_connection) @app.get("/", dependencies=[Depends(RateLimiter(times=2, seconds=5))]) 0 comments on commit c85c9e8 Please sign in...
A request rate limiter for fastapi. Contribute to wu-clan/fastapi-limiter development by creating an account on GitHub.
from fastapi_limiter.depends import RateLimiter, WebSocketRateLimiter app = FastAPI() @@ -34,17 +34,19 @@ async def index(): async def multiple(): return {"msg": "Hello World"} @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() ratelimit...
what i did is just add an exception that return 0 for pexpire if redis is unavailable in depends:RateLimiter class: async def _check(self, key): redis = FastAPILimiter.redis try: pexpire = await redis.evalsha( FastAPILimiter.lua_sha, 1, key, str(self.times), str(self.milliseconds) )...
long2ice / fastapi-limiter Public Notifications Fork 54 Star 518 New issue Jump to bottom IP control #50 Open patrickpasquini opened this issue Jan 25, 2024· 0 comments Open IP control #50 patrickpasquini opened this issue Jan 25, 2024· 0 comments Comments patrickpasquini ...
$ poetry add fastapi-simple-rate-limiter Github Installing the latest version from Github: $ git clone https://github.com/jintaekimmm/fastapi-simple-rate-limiter $ cd fastapi-simple-rate-limiter $ python setup.py install Usage To use this package, please add rate_limiter decorator to the Fas...