python - How to immediately sent 200 Ok response in Flask? - Stack Overflow

I am trying to integrate Payfast on my flask application. The users are able to make payments but the I

I am trying to integrate Payfast on my flask application. The users are able to make payments but the ITN is not sent back. I always get the 307 Temporary Redirect response instead of 200 Ok. I am using flask so I have no idea why I always get this response.

In their documentation, they give a PHP example:

// Tell Payfast that this page is reachable by triggering a header 200
header('HTTP/1.0 200 OK');
flush();

I have tried everything like the following:

@orders.route('/status/notify', methods=['GET', 'POST'], strict_slashes=False)
def notify():
    return 'Ok', 200
@orders.route('/status/notify', methods=['GET', 'POST'])
@orders.route('/status/notify/', methods=['GET', 'POST'])
def notify():
    return 'Ok', 200
@orders.route('/status/notify', methods=['GET', 'POST'], strict_slashes=False)
def notify():
    current_app.logger.debug("Request received:")
    current_app.logger.debug(f"Method: {request.method}")
    current_app.logger.debug(f"Headers: {request.headers}")
    current_app.logger.debug(f"Data: {request.get_data()}")
    current_app.logger.debug(f"URL: {request.url}")

    pf_data = request.get_data()

    response = Response('OK', status=200)
    response.headers['Connection'] = 'close'
    return 'Ok'

And none of these work, I always get the same response.

How would I prevent the auto redirection for this route?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744808812a4594941.html

相关推荐

  • python - How to immediately sent 200 Ok response in Flask? - Stack Overflow

    I am trying to integrate Payfast on my flask application. The users are able to make payments but the I

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信