MakPr016 commited on
Commit ·
20ffbac
1
Parent(s): c8a5297
Updated Limiter
Browse files- app/limiter.py +8 -3
- requirements.txt +152 -6
- test.py +11 -0
app/limiter.py
CHANGED
|
@@ -1,5 +1,10 @@
|
|
| 1 |
from slowapi import Limiter
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from slowapi import Limiter
|
| 2 |
+
from starlette.requests import Request
|
| 3 |
|
| 4 |
+
def get_real_ip(request: Request) -> str:
|
| 5 |
+
forwarded_for = request.headers.get("X-Forwarded-For")
|
| 6 |
+
if forwarded_for:
|
| 7 |
+
return forwarded_for.split(",")[0].strip()
|
| 8 |
+
return request.client.host
|
| 9 |
+
|
| 10 |
+
limiter = Limiter(key_func=get_real_ip)
|
requirements.txt
CHANGED
|
@@ -1,6 +1,152 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate==1.12.0
|
| 2 |
+
addict==2.4.0
|
| 3 |
+
annotated-doc==0.0.4
|
| 4 |
+
annotated-types==0.7.0
|
| 5 |
+
anyio==4.12.1
|
| 6 |
+
attrs==25.4.0
|
| 7 |
+
babel==2.18.0
|
| 8 |
+
blinker==1.9.0
|
| 9 |
+
blis==1.3.3
|
| 10 |
+
catalogue==2.0.10
|
| 11 |
+
certifi==2026.1.4
|
| 12 |
+
cffi==2.0.0
|
| 13 |
+
charset-normalizer==3.4.4
|
| 14 |
+
click==8.3.1
|
| 15 |
+
cloudpathlib==0.23.0
|
| 16 |
+
colorama==0.4.6
|
| 17 |
+
confection==0.1.5
|
| 18 |
+
cryptography==46.0.5
|
| 19 |
+
csvw==3.7.0
|
| 20 |
+
curated-tokenizers==0.0.9
|
| 21 |
+
curated-transformers==0.1.1
|
| 22 |
+
cymem==2.0.13
|
| 23 |
+
Deprecated==1.3.1
|
| 24 |
+
diffusers==0.36.0
|
| 25 |
+
diskcache==5.6.3
|
| 26 |
+
dlinfo==2.0.0
|
| 27 |
+
docopt==0.6.2
|
| 28 |
+
dpcpp-cpp-rt==2025.3.1
|
| 29 |
+
en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl#sha256=1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85
|
| 30 |
+
espeakng-loader==0.2.4
|
| 31 |
+
exceptiongroup==1.3.1
|
| 32 |
+
fastapi==0.129.0
|
| 33 |
+
filelock==3.20.0
|
| 34 |
+
Flask==3.1.2
|
| 35 |
+
fsspec==2025.12.0
|
| 36 |
+
gguf==0.17.1
|
| 37 |
+
h11==0.16.0
|
| 38 |
+
hf-xet==1.2.0
|
| 39 |
+
httpcore==1.0.9
|
| 40 |
+
httpx==0.28.1
|
| 41 |
+
huggingface_hub==1.4.1
|
| 42 |
+
idna==3.11
|
| 43 |
+
importlib_metadata==8.7.1
|
| 44 |
+
intel-cmplr-lib-rt==2025.3.1
|
| 45 |
+
intel-cmplr-lib-ur==2025.3.1
|
| 46 |
+
intel-cmplr-lic-rt==2025.3.1
|
| 47 |
+
intel-extension-for-transformers==1.4.2
|
| 48 |
+
intel-opencl-rt==2025.3.1
|
| 49 |
+
intel-openmp==2025.3.1
|
| 50 |
+
intel-pti==0.15.0
|
| 51 |
+
intel-sycl-rt==2025.3.1
|
| 52 |
+
isodate==0.7.2
|
| 53 |
+
itsdangerous==2.2.0
|
| 54 |
+
Jinja2==3.1.6
|
| 55 |
+
joblib==1.5.3
|
| 56 |
+
jsonschema==4.26.0
|
| 57 |
+
jsonschema-specifications==2025.9.1
|
| 58 |
+
kokoro==0.9.4
|
| 59 |
+
language-tags==1.2.0
|
| 60 |
+
loguru==0.7.3
|
| 61 |
+
markdown-it-py==4.0.0
|
| 62 |
+
MarkupSafe==2.1.5
|
| 63 |
+
mdurl==0.1.2
|
| 64 |
+
misaki==0.9.4
|
| 65 |
+
mkl==2025.3.0
|
| 66 |
+
mpmath==1.3.0
|
| 67 |
+
murmurhash==1.0.15
|
| 68 |
+
networkx==3.4.2
|
| 69 |
+
neural_compressor==3.7.1
|
| 70 |
+
num2words==0.5.14
|
| 71 |
+
numpy==1.26.4
|
| 72 |
+
onemkl-license==2025.3.0
|
| 73 |
+
onemkl-sycl-blas==2025.3.0
|
| 74 |
+
onemkl-sycl-dft==2025.3.0
|
| 75 |
+
onemkl-sycl-lapack==2025.3.0
|
| 76 |
+
onemkl-sycl-rng==2025.3.0
|
| 77 |
+
onemkl-sycl-sparse==2025.3.0
|
| 78 |
+
opencv-python-headless==4.11.0.86
|
| 79 |
+
packaging==26.0
|
| 80 |
+
pandas==2.3.3
|
| 81 |
+
pdfminer.six==20251230
|
| 82 |
+
pdfplumber==0.11.9
|
| 83 |
+
phonemizer-fork==3.3.2
|
| 84 |
+
pillow==12.0.0
|
| 85 |
+
preshed==3.0.12
|
| 86 |
+
prettytable==3.17.0
|
| 87 |
+
psutil==7.2.2
|
| 88 |
+
py-cpuinfo==9.0.0
|
| 89 |
+
pycocotools==2.0.11
|
| 90 |
+
pycparser==3.0
|
| 91 |
+
pydantic==2.12.5
|
| 92 |
+
pydantic_core==2.41.5
|
| 93 |
+
pyelftools==0.32
|
| 94 |
+
Pygments==2.19.2
|
| 95 |
+
pyparsing==3.3.2
|
| 96 |
+
pypdfium2==5.4.0
|
| 97 |
+
python-dateutil==2.9.0.post0
|
| 98 |
+
python-dotenv==1.2.1
|
| 99 |
+
python-multipart==0.0.22
|
| 100 |
+
pytz==2025.2
|
| 101 |
+
PyYAML==6.0.3
|
| 102 |
+
rdflib==7.6.0
|
| 103 |
+
referencing==0.37.0
|
| 104 |
+
regex==2026.1.15
|
| 105 |
+
requests==2.32.5
|
| 106 |
+
rfc3986==1.5.0
|
| 107 |
+
rich==14.3.2
|
| 108 |
+
rpds-py==0.30.0
|
| 109 |
+
safetensors==0.7.0
|
| 110 |
+
schema==0.7.8
|
| 111 |
+
scikit-learn==1.7.2
|
| 112 |
+
scipy==1.15.3
|
| 113 |
+
segments==2.3.0
|
| 114 |
+
shellingham==1.5.4
|
| 115 |
+
six==1.17.0
|
| 116 |
+
smart_open==7.5.0
|
| 117 |
+
soundfile==0.13.1
|
| 118 |
+
spacy==3.8.11
|
| 119 |
+
spacy-curated-transformers==0.3.1
|
| 120 |
+
spacy-legacy==3.0.12
|
| 121 |
+
spacy-loggers==1.0.5
|
| 122 |
+
srsly==2.5.2
|
| 123 |
+
starlette==0.52.1
|
| 124 |
+
sympy==1.14.0
|
| 125 |
+
tbb==2022.3.0
|
| 126 |
+
tcmlib==1.4.1
|
| 127 |
+
termcolor==3.3.0
|
| 128 |
+
thinc==8.3.10
|
| 129 |
+
threadpoolctl==3.6.0
|
| 130 |
+
tokenizers==0.22.2
|
| 131 |
+
torch==2.10.0+xpu
|
| 132 |
+
torchaudio==2.10.0+xpu
|
| 133 |
+
torchvision==0.25.0+xpu
|
| 134 |
+
tqdm==4.67.3
|
| 135 |
+
transformers==5.1.0
|
| 136 |
+
triton-xpu==3.6.0
|
| 137 |
+
typer==0.23.0
|
| 138 |
+
typer-slim==0.23.0
|
| 139 |
+
typing-inspection==0.4.2
|
| 140 |
+
typing_extensions==4.15.0
|
| 141 |
+
tzdata==2025.3
|
| 142 |
+
umf==1.0.2
|
| 143 |
+
uritemplate==4.2.0
|
| 144 |
+
urllib3==2.6.3
|
| 145 |
+
uvicorn==0.40.0
|
| 146 |
+
wasabi==1.1.3
|
| 147 |
+
wcwidth==0.6.0
|
| 148 |
+
weasel==0.4.3
|
| 149 |
+
Werkzeug==3.1.5
|
| 150 |
+
win32_setctime==1.2.0
|
| 151 |
+
wrapt==2.1.1
|
| 152 |
+
zipp==3.23.0
|
test.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
url = "https://makpr016-sdg-api.hf.space/classify"
|
| 4 |
+
payload = {"text": "clean water for rural communities", "top_k": 3}
|
| 5 |
+
|
| 6 |
+
for i in range(25):
|
| 7 |
+
response = requests.post(url, json=payload)
|
| 8 |
+
print(f"Request {i+1}: Status {response.status_code}")
|
| 9 |
+
if response.status_code == 429:
|
| 10 |
+
print("RATE LIMITED:", response.text)
|
| 11 |
+
break
|