如何获取URL


1、使用url_for获取URL

@app.route('/')
def index():
    return url_for('article')


@app.route('/article/')
def article():
    return 'article'

2、获取带参数的URL

@app.route('/')
def index():
    return url_for('article', aid=1)


@app.route('/article/<aid>/')
def article(aid):
    return aid

results matching ""

    No results matching ""