Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
deleted 18 characters in body
Source Link
STA
  • 35.3k
  • 9
  • 49
  • 62

If you have same class name and want to map with multiple routes, then specify the endpoint, so that framework will differentiate between two:

>  class ClassName(Resource):
>         def get(self):
>             if request.endpoint!='hello':
>                 return {"data": "Hello"}
>             elif:
>                 return {"data" : "World"}
>                 
>     api.add_resource(ClassName, '/rout1', endpoint = "world")
>     api.add_resource(ClassName, '/rout2', endpoint="hello")

If you have same class name and want to map with multiple routes, then specify the endpoint, so that framework will differentiate between two:

>  class ClassName(Resource):
>         def get(self):
>             if request.endpoint!='hello':
>                 return {"data": "Hello"}
>             elif:
>                 return {"data" : "World"}
>                 
>     api.add_resource(ClassName, '/rout1', endpoint = "world")
>     api.add_resource(ClassName, '/rout2', endpoint="hello")

If you have same class name and want to map with multiple routes, then specify the endpoint, so that framework will differentiate between two:

 class ClassName(Resource):
        def get(self):
            if request.endpoint!='hello':
                return {"data": "Hello"}
            elif:
                return {"data" : "World"}
                
    api.add_resource(ClassName, '/rout1', endpoint = "world")
    api.add_resource(ClassName, '/rout2', endpoint="hello")
Source Link

If you have same class name and want to map with multiple routes, then specify the endpoint, so that framework will differentiate between two:

>  class ClassName(Resource):
>         def get(self):
>             if request.endpoint!='hello':
>                 return {"data": "Hello"}
>             elif:
>                 return {"data" : "World"}
>                 
>     api.add_resource(ClassName, '/rout1', endpoint = "world")
>     api.add_resource(ClassName, '/rout2', endpoint="hello")