Does Sanic have a 'url_for()' function (like in flask)?

1.1k Views Asked by At

I'm trying to port a simple flask app to sanic, working with the example for sanic and jinja.

Does sanic have a url_for() function like flask?

2

There are 2 best solutions below

0
On BEST ANSWER

Update: Sanic 0.3.1 adds support for url_for():

url = app.url_for('post_handler', post_id=5, arg_one='one', arg_two='two')

No. Currently sanic's router is very basic and does not support lookups. You can review the short source code here: https://github.com/channelcat/sanic/blob/master/sanic/router.py

0
On

Now the sanic support url_for method

resource code