Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 688
user666 Avatar asked Dec 27 '16 06:12

user666


2 Answers

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

like image 185
Udi Avatar answered Nov 03 '22 01:11

Udi


Now the sanic support url_for method

resource code

like image 41
agnewee Avatar answered Nov 02 '22 23:11

agnewee