I'm trying to transfer a file to the CherryPy server from a client in Python 3.
Client part:
import requests url = 'http://127.0.0.1:8080/upload' files = {'file.zip': open('file.zip', 'rb')} r = requests.post(url, files=files) print(r.status_code == requests.codes.ok) Server part:
import os import tempfile import shutil import cherrypy config = { 'global' : { 'server.socket_host' : '127.0.0.1', 'server.socket_port' : 8080, 'server.thread_pool' : 8, 'server.max_request_body_size' : 0, 'server.socket_timeout' : 60 } } class App: @cherrypy.config(**{'response.timeout': 3600}) @cherrypy.expose() def upload(self): '''Handle non-multipart upload''' destination = os.path.join('/home/uvv/upload') with open(destination, 'wb') as f: shutil.copyfileobj(cherrypy.request.body, f) return 'Okay' if __name__ == '__main__': cherrypy.quickstart(App(), '/', config) Accordingly, the server returns: 127.0.0.1 - - [17 / Aug / 2016: 11: 38: 49] "POST / upload HTTP / 1.1" 400 2083 "" "python-requests / 2.10.0" And the client: False I can not understand why the file is not loading. Yes, the rights to the / home / uvv / upload folder are a + rwx (therefore, the problem is definitely not the permissions)