Spaces:
Sleeping
Sleeping
feat: limit page range to 300 max
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- app.py +4 -0
- static/index.html +2 -2
app.py
CHANGED
|
@@ -32,6 +32,10 @@ async def extract(
|
|
| 32 |
):
|
| 33 |
if not pdf.filename.lower().endswith(".pdf"):
|
| 34 |
raise HTTPException(status_code=400, detail="Le fichier doit être un PDF.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
with tempfile.NamedTemporaryFile(suffix=".pdf", delete=False) as tmp:
|
| 37 |
shutil.copyfileobj(pdf.file, tmp)
|
|
|
|
| 32 |
):
|
| 33 |
if not pdf.filename.lower().endswith(".pdf"):
|
| 34 |
raise HTTPException(status_code=400, detail="Le fichier doit être un PDF.")
|
| 35 |
+
if page_to > 300:
|
| 36 |
+
raise HTTPException(status_code=400, detail="La limite est de 300 pages maximum.")
|
| 37 |
+
if page_from > page_to:
|
| 38 |
+
raise HTTPException(status_code=400, detail="La page de début doit être ≤ à la page de fin.")
|
| 39 |
|
| 40 |
with tempfile.NamedTemporaryFile(suffix=".pdf", delete=False) as tmp:
|
| 41 |
shutil.copyfileobj(pdf.file, tmp)
|
static/index.html
CHANGED
|
@@ -238,7 +238,7 @@
|
|
| 238 |
<label>
|
| 239 |
Page de
|
| 240 |
<div class="range-row">
|
| 241 |
-
<input type="range" id="pageFrom" name="page_from" min="1" max="
|
| 242 |
<span class="range-val" id="pageFromVal">1</span>
|
| 243 |
</div>
|
| 244 |
</label>
|
|
@@ -246,7 +246,7 @@
|
|
| 246 |
<label>
|
| 247 |
Page à
|
| 248 |
<div class="range-row">
|
| 249 |
-
<input type="range" id="pageTo" name="page_to" min="1" max="
|
| 250 |
<span class="range-val" id="pageToVal">10</span>
|
| 251 |
</div>
|
| 252 |
</label>
|
|
|
|
| 238 |
<label>
|
| 239 |
Page de
|
| 240 |
<div class="range-row">
|
| 241 |
+
<input type="range" id="pageFrom" name="page_from" min="1" max="300" value="1" />
|
| 242 |
<span class="range-val" id="pageFromVal">1</span>
|
| 243 |
</div>
|
| 244 |
</label>
|
|
|
|
| 246 |
<label>
|
| 247 |
Page à
|
| 248 |
<div class="range-row">
|
| 249 |
+
<input type="range" id="pageTo" name="page_to" min="1" max="300" value="10" />
|
| 250 |
<span class="range-val" id="pageToVal">10</span>
|
| 251 |
</div>
|
| 252 |
</label>
|