[Python] Add a prefix to all Flask routes

Discussão em 'Python' iniciado por Stack, Dezembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    I have a prefix that I want to add to every route. Right now I add a constant to the route at every definition. Is there a way to do this automatically?

    PREFIX = "/abc/123"

    @app.route(PREFIX + "/")
    def index_page():
    return "This is a website about burritos"

    @app.route(PREFIX + "/about")
    def about_page():
    return "This is a website about burritos"

    Continue reading...

Compartilhe esta Página