xxxxxxxxxx
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def result():
print(request.data) # raw data
print(request.json) # json (if content-type of application/json is sent with the request)
print(request.get_json(force=True)) # json (if content-type of application/json is not sent)
xxxxxxxxxx
from flask import Flask, request
app = Flask(__name__)
@app.route('/api', methods=['POST'])
def api_endpoint():
data = request.get_json() # Access the request payload
# Process the request data
# ...
# Return a response
return 'POST request received'
if __name__ == '__main__':
app.run()