A FastAPI decorator for rate limiting requests based on specified parameters.
Project description
Installation
pip install fastapi-request-limit
Usage
Here's how you can use the request-limit decorator in a FastAPI application:~
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi_request_limit import request_limit
app = FastAPI()
@app.post("/", response_class=JSONResponse)
@request_limit(seconds=5, data=["foo", "bar"])
async def root(foo: str, bar: int, request: Request):
return JSONResponse(content={"message": f"Request accepted for {foo} and {bar}"})
Parameters
- seconds (int): The number of seconds required between requests with the same parameter values.
- data (List[str]): A list of parameter names to use for rate limiting.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for fastapi_request_limit-0.1.4.tar.gz
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | d8de353ab48c37ddcfe8a48833b8a98ca1953471c62e2d54e55ac18601a58a7c |
|
| MD5 | 56b8be70968a3acfde53c1de618e6efe |
|
| BLAKE2b-256 | 60b4cdd28600f61d22a6ed80bb5199caf12c2711440a2866c0767ee523a947b4 |
Close
Hashes for fastapi_request_limit-0.1.4-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 95dc84a49d93d3b040c0202459b2a528fa9e5938f3e901cd8e7a0630b16d8e19 |
|
| MD5 | 5d401ea5e4aab2a0248fe05b363bb2a8 |
|
| BLAKE2b-256 | b6c1c3c974c12649828a958f5750daa66719beba0994b89f767faaf561c6cdd1 |