Python Forum

Full Version: flask webhook response
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey, new to python and trying to get the data from my webhook response, tried a bunch of methods all not changing the result.

from actions import send_order, parse_webhook
from auth import get_token
from flask import Flask, request, abort
import json


# Create Flask object called app.
app = Flask(__name__)


print("HELLO1")


# Create root to easily let us know its on/working.
@app.route('/', methods=['GET', 'POST'])
def root():
    return 'online'


print("HELLO2")


def webhook():
    print("HELLO3")
    if request.method == 'POST':
        print("HELLO4")
        print(request.json)
        return '', 200
    else:
        abort(400)
        print("HELLO5")


if __name__ == '__main__':
    print("HELLO6")
    app.run(host='0.0.0.0', port=80)
    print("HELLO7")
when my ngrok server gets a request this is the only thing that appears in the console.

127.0.0.1 - - [28/Aug/2020 02:08:26] "POST / HTTP/1.1" 200 -

it is a POST code 200 with this data i can see on the ngrok page but no dice on the webhook.
also no errors from the server.py file

key:"1234,
TICKER: BTCUSDT,
EXCHANGE: BINANCE,
OPEN: 11353.764322832612
CLOSE: 11341.56

also the only "HELLO" prints that appear are
HELLO1
HELLO2
HELLO6
I still haven't figured this out, sorry if this is not enough info here is the full console after I have received 2 POST responses.

HELLO1
HELLO2
HELLO6
 * Serving Flask app "webhook" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
127.0.0.1 - - [29/Aug/2020 04:24:36] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [29/Aug/2020 04:25:02] "POST / HTTP/1.1" 200 -
On ngrok i get POST /200 OK 1ms as well so it looks like I'm receiving it fine just can't get the data out of it