With Flask server:
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
print('get_json: %s get_data: %s' % (type(request.get_json()), type(request.get_data())) )
return 'OK', 200
app.run('0.0.0.0', 80)
the Client sends a request using both json
and files
arguments:
import requests
files_data = {"dirname/file,name": bytearray(4)}
response = requests.post('http://127.0.0.1:80/', json = 'hello world', files = files_data)
the server prints that request.get_json()
returns None
.
get_json: <type 'NoneType'> get_data: <type 'str'>
How to pass hello world
string to server?