python handling a post request

Solutions on MaxInterview for python handling a post request by the best coders in the world

showing results for - "python handling a post request"
Keri
20 Sep 2017
1# first do: pip install flask
2
3from flask import Flask, request
4
5app = Flask(__name__)
6
7@app.route('/', methods=['POST'])
8def result():
9    print(request.data)  # raw data
10    print(request.json)  # json (if content-type of application/json is sent with the request)
11    print(request.get_json(force=True))  # json (if content-type of application/json is not sent)
12