I have been asked to understand and maintain code like the following code block.
@app.route("/api/v1/users/register/", methods=["POST"])
def register():
data = {
"lat": request.data.get("lat", ""),
"lon": request.data.get("lon", ""),
"is_bl_allowed": request.data.get("is_bl_allowed", 1),
"is_loc_allowed": request.data.get("is_loc_allowed", 1),
"is_bl_on": request.data.get("is_bl_on", 1),
"is_loc_on": request.data.get("is_loc_on", 1)
}
Imports are
from flask import make_response
from flask import request, jsonify
import requests
I thought flask request used get_json or form.get to retrive POST request data. I am not sure what is being retrieved in this code block. I do not have access to the code that is calling this API. If anyone can explain what the request.data.get does, what its return value would be and why it takes 2 parameters, that would be awesome.
Thanks in advance.