Python 3.5中的一段代码正确地进行了剪贴,以便通过api-rest(在Django 1.10.4中正在运行一个项目)将产品保存在mysql服务器中。
更改服务器后,在执行方法PUT时为了保存产品(Json格式),它已开始引发错误500。与Nginx和Gunicorn一起运行的服务器的配置如下:
server {
listen 80;
server_name www.xxxxxxxx.es;
return 301 https://www.xxxxxxx.es$request_uri;
}
server {
listen 443 default ssl;
ssl_certificate /etc/letsencrypt/live/xxxxxx.es-0001/fullchain.pem; #
ssl_certificate_key /etc/letsencrypt/live/xxxxxx.es-0001/privkey.pem;
client_max_body_size 5M;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/thebest5;
}
location /media/ {
root /home/ubuntu/thebest5;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/thebest5/thebest5.sock;
}
}
在进行调试时,此行中存储产品的python中的scraper代码失败:
response = requests.put(API_URL + 'scan/' + str(self.search_tag[id]), data=
json.dumps(self.search_tag), headers={'Authorization': 'JWT ' + self.token,
'Content-Type':'application/json'})
在它试图将产品保存到数据库服务器中之前,该剪贴器运行良好,然后PUT方法失败并出现500错误。错误提示:
C:\Users\ana\Anaconda3\lib\site-
packages\requests\packages\urllib3\response.py in _update_chunk_length(self)
534 try:
535 self.chunk_left = int(line, 16)
536 except ValueError:
ValueError: invalid literal for int() with base 16: b''