Is there url_for() in eve?

Question:

We know in Flask, there is url_for() for endpoint,
like url_for('edit', _external=True)
I what to ask what’s the best practice in python eve ?

Asked By: Gladuo

||

Answers:

Since eve is Flask application url_for works well.
e.g.

$ python manage.py shell
In [1]: from flask import url_for

In [2]: url_for('home')
Out[2]: '/'

In [3]: url_for('users|resource')
Out[3]: '/users'

In the above example users is one of the collection. There are few more that would work conditionally like 'users|item_lookup, users|item_post_override etc. (They don’t work on my setup due to my own settings.py file)

To learn more, have a look at the flaskapp.py file, and search for add_url_rule

Answered By: Mandar Vaze
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.