使用Python Bottle将POST数据重定向到url

Sky*_*nex 4 python redirect bottle

有没有办法在重定向到另一个页面时添加POST数据?

我已经构建了一个服务,它将用户重定向到调用服务时指定的任何页面.问题是由于复杂和写得不好的重写规则等原因,我无法在url上放置任何GET参数.所以我需要用POST发送一个值.无论如何添加到Bottles redirect(return_url)或在Python中使用其他一些lib?

mik*_*ike 8

您可以构建response,而不是使用redirect(url)瓶子的方法

from bottle import route, run, response

@post('/wrong')
def wrong():
  response.status = 303
  response.set_header('Location', '/hello')
  return '"key":"val"'  # Enter the body here

@route('/hello')
def hello():
  return "Hello World!"

run(host='0.0.0.0', port=8080, debug=True)
Run Code Online (Sandbox Code Playgroud)