[FIXED] How to handle a post request in json format to own laptop in python via django or flask


I configured an http webhook on the thethingsstack web page cloud.thethings.network. This HTTP webhook does a post request to a configured endpoint (my laptop) like this:

http://xxx.ngrok.io -> http://localhost:80
For uplink messages: http://localhost:80/uplink-message
For join confirmation: http://localhost:80/join-accept

You can also see that you receive post requests on the command line using ngrok.exe http 80.

POST /uplink-enabled 502 Bad Gateway POST /uplink-enabled 502 Bad Gateway POST /uplink-enabled 502 Bad Gateway

However, I am unable to receive the data in json format according to the online tutorial.
Enter link description here
Enter link description here
Is there a code example that continuously listens to the http port and handles post requests?

My flask code looks like this:

# import main Flask class and request object
from Flask import Flask, request

# Create a Flask app
app = Flask(__name__)

def query_example():
    return 'example query string'

If __name__ == '__main__':
    # Run app in debug mode on port 5000
    app.run(debug=True, port=80)

I can also check the incoming post request, but I get an error:

  • Debug Mode: On *Rebooting with stat *Debugger Active!*
    Debugger PIN: 852-174-427 * Run with (
    CTRL+C to exit) – – [Aug 18 2021 11:12:46] “POST /uplink-enabled HTTP/1.1” 405 –

My ngrok interface looks like this:

Session Status Online
Session expires in 1 hour and 19 minutes
Version 2.3.40
Region United States (us)
Web interface
Forward http://xxx.ngrok.io ->
http://localhost:80 transfer
https://xxx.ngrok.io -> http://localhost:80


@app.route('/uplink-enabled', methods= ['POST', 'GET'])
def query_example():
    return 'Query String Example'

This will handle 405 error.

Answered By – Amith Lakkakula

Answer Checked By – Cary Denson (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published