Skip to content

Commit

Permalink
tried to fix limiter exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh4517 committed Sep 21, 2024
1 parent e4ba1d2 commit b85b289
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/paste/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
RedirectResponse,
JSONResponse,
)
from starlette.requests import Request
from starlette.responses import Response
from typing import Callable, Awaitable, List, Optional
import shutil
import os
import json
Expand All @@ -30,9 +33,8 @@
from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.formatters import HtmlFormatter
from pygments.util import ClassNotFound
from typing import List, Optional
from . import __version__, __author__, __contact__, __url__
from .schema import PasteCreate, PasteDetails, PasteResponse
from .schema import PasteCreate, PasteResponse, PasteDetails

description: str = "paste.py 🐍 - A pastebin written in python."

Expand All @@ -51,7 +53,11 @@
redoc_url=None,
)
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)

async def rate_limit_exceeded_handler(request: Request, exc: RateLimitExceeded) -> Response:
return await _rate_limit_exceeded_handler(request, exc)

app.add_exception_handler(RateLimitExceeded, rate_limit_exceeded_handler)

origins: List[str] = ["*"]

Expand Down

0 comments on commit b85b289

Please sign in to comment.