Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

decorative view function two times #42

Open
beafuture opened this issue Nov 24, 2015 · 2 comments
Open

decorative view function two times #42

beafuture opened this issue Nov 24, 2015 · 2 comments

Comments

@beafuture
Copy link

Hi!
I want decorative view function two times with @route decorator like this:

@route(bp,'/')
@route(bp,'/<int:id>')
def index(id):
    .....

bug i get error "View function mapping is overwriting an existing endpoint", is there a way to meet this demand?

@beafuture beafuture changed the title decorative view function two times 偗 decorative view function two times Nov 24, 2015
@scottwernervt
Copy link

I believe you just set id=None and remove @route(bp,'/'):

@route(bp,'/<id:int>')
def index(id=None):
    .....

Also see http://flask.pocoo.org/snippets/57/. In the future, post questions like this to stackoverflow/flask mailing list as the question is related to Flask, not the overholt structure.

@beafuture
Copy link
Author

The flask original @route decorator is wrapped in api/init.py. I do what you say is not correct. When i access http://x.x.x.x/api/xxx/ get 404 error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants