[Python] I have a problem with the parameters in fastapi

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have this application in fastapi. through a get request the page and area2 parameters are passed, the page parameter is correctly captured but the area2 is not, it returns none

    @router.get("/")
    async def home(request: Request, db: Session = Depends(get_db), page:int= 1, area2: str=None):
    print(page, area2)
    ...


    This is my html

    <span class="step-links" >
    {% if page_obj.has_previous %}
    <a href="?page=1?&area2={{area}}">&laquo; first</a>
    <a href="?page={{ page_obj.number-1}}&?area={{area}}"> --previous </a>
    {% endif %}

    Continue reading...

Compartilhe esta Página