Thanks to Craig answer, I found the solution. I will post both code ( client and server ) to help in case of future use. The CLient server is uploading file and Json in the "form" feature of flask. Then some ast and some dict to make the Payload clearer ( I know this is ugly way, but this is the best scholar approach )
On Client side :
datas = {'CurrentMail': "AA", 'STRUserUUID1': "BB", 'FirstName': "ZZ", 'LastName': "ZZ", 'EE': "RR", 'JobRole': "TT" }
#sending user infos to app server using python "requests"
url = "http://10.100.2.6:80/customerupdate"
def send_request():
payload = datas
local_file_to_send = 'user_picture.jpg'
files = {
'json': (None, json.dumps(payload), 'application/json'),
'file': (os.path.basename(local_file_to_send), open(local_file_to_send, 'rb'), 'application/octet-stream')
}
r = requests.post(url, files=files)
send_request()
On Flask Server side :
import sys, os, logging, time, datetime, json, uuid, requests, ast
from flask import Flask, request , render_template
from werkzeug import secure_filename
from werkzeug.datastructures import ImmutableMultiDict
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
app.debug = True
class OPERATIONS(Resource):
@app.route('/',methods=['GET'])
def hello_world():
return 'Hello World!'
@app.route('/customerupdate',methods=['GET','POST'])
def customerupdate():
print "************DEBUG 1 ***********"
RequestValues = request.values
print RequestValues
print "************DEBUG 2 ***********"
RequestForm = request.form
print RequestForm
print "************DEBUG 2-1 ***********"
so = RequestForm
json_of_metadatas = so.to_dict(flat=False)
print json_of_metadatas
print "************DEBUG 2-2 ***********"
MetdatasFromJSON = json_of_metadatas['json']
print MetdatasFromJSON
print "************DEBUG 2-3 ***********"
MetdatasFromJSON0 = MetdatasFromJSON[0]
print MetdatasFromJSON0
print "************DEBUG 3-5 ***********"
strMetdatasFromJSON0 = str(MetdatasFromJSON0)
MetdatasDICT = ast.literal_eval(strMetdatasFromJSON0)
print MetdatasDICT
print "************DEBUG 3-5 ***********"
for key in MetdatasDICT :
print "key: %s , value: %s" % (key, MetdatasDICT[key])
print "************DEBUG 4 ***********"
f = request.files['file']
f.save(secure_filename(f.filename))
print "FILE SAVED LOCALY"
return 'JSON of customer posted'