Пример #1
0
@app.route('/show/<int:id>')
def test_sync_args(id):
    return id


@app.route('/test_post', methods=['GET', 'POST'])
def test_post():
    if app.request.method == 'GET':
        return app.render('test_post.html')
    return app.request.form["title"], app.request.form["tag"]


@app.route('/test_redirect')
def test_redirect():
    return app.redirect('/')


@app.route('/redirect_with_args')
def test_redirect_with_url():
    return app.redirect(app.url_for(test_sync_args, id=1))


@app.route('/test_jsonify')
def test_jsonify():
    return app.jsonify(name='lunar')


if __name__ == '__main__':
    app.run(debug=True)
Пример #2
0
@app.route('/show/<int:id>')
def test_sync_args(id):
    return id


@app.route('/test_post', methods=['GET', 'POST'])
def test_post():
    if app.request.method == 'GET':
        return app.render('test_post.html')
    return app.request.form["title"], app.request.form["tag"]


@app.route('/test_redirect')
def test_redirect():
    return app.redirect('/')


@app.route('/redirect_with_args')
def test_redirect_with_url():
    return app.redirect(app.url_for(test_sync_args, id=1))


@app.route('/test_jsonify')
def test_jsonify():
    return app.jsonify(name='lunar')


if __name__ == '__main__':
    app.run(debug=True)