Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
flask webhook response
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Return Frame as well as JSON response using same API in Flask Python Ask jenkins43 0 1,865 May-11-2020, 04:58 PM
Last Post: jenkins43
  Flask Create global response function to be called from every where in the web app umen 2 2,300 Apr-14-2020, 09:54 PM
Last Post: umen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020