[英]Apache, mod_wsgi, Django, and a Python user agent
I am having a problem with a user agent written in Python that I am now trying to use with a Bitnami Amazon Web Service that has Apache, mod_wsgi (for Python), and Django pre-installed. 我遇到了一个用Python编写的用户代理问题,现在我正尝试将其与预先安装了Apache,mod_wsgi(用于Python)和Django的Bitnami Amazon Web Service一起使用。 I am having a problem when trying to POST data to the Django site from the Python user agent.
尝试将数据从Python用户代理发布到Django站点时遇到问题。
For instance, when I assemble an URL with the following: 例如,当我用以下命令组装一个URL时:
rq = urllib2.Request('http://' + IP_ADDRESS + '/power/command/')
r = urllib2.urlopen(rq)
return r.read()
This GET is no problem. 这个GET没问题。 When I assemble an URL as follows, but try to POST data with it, like so:
当我按以下方式组装URL时,请尝试使用它来发布数据,如下所示:
params = urlencode({'u': json.write(obj)})
rq = urllib2.Request('http://' + IP_ADDRESS + '/power/command/update/', params)
r = urllib2.urlopen(rq)
ret_val = r.read()
I get a 404 error. 我收到404错误。 If I simply remove the params from the Request constructor, I get a 500 error – which is more or less appropriate.
如果仅从Request构造函数中删除参数,则会出现500错误-或多或少是适当的。
Both of these segments of code work just fine with the Django debug webserver('./manage.py runserver') that is part of Django. 这两个代码段都可以与Django的一部分Django调试网络服务器('./manage.py runserver')配合使用。 Any ideas on the problem, or even just how to debug are appreciated.
对此问题的任何想法,甚至只是如何调试的想法,都应受到赞赏。
I have already tried to spoof the 'User-agent', but this doesn't seem likely since the GET works in the first instance. 我已经尝试欺骗'User-agent',但这似乎不太可能,因为GET在第一个实例中起作用。 The Apache httpd.conf file seems pretty stock except for the mod_wsgi references.
除了mod_wsgi引用之外,Apache httpd.conf文件似乎非常实用。 I had this working on a local development server at one time, but I can't seem to find the differences.
我曾经一次在本地开发服务器上工作,但是似乎找不到差异。 I'm sure it's a configuration thing since the code works in the dev environment and with the debug server.
我确定这是一个配置问题,因为代码可在开发环境和调试服务器中工作。
As a start, check your Apache access and error logs and see if you find something fishy over there: 首先,请检查您的Apache访问和错误日志,看看是否在那儿发现了一些可疑之处:
How to debug errors?
如何调试错误?
Once Apache starts, it will create two log files, the access_log and the error_log / installdir /apache2/logs directory.
Apache启动后,它将创建两个日志文件,access_log和error_log / installdir / apache2 / logs目录。 You can change these files to see the exact error in the application.
您可以更改这些文件以查看应用程序中的确切错误。
from: http://wiki.bitnami.org/Components/Apache#How_to_debug_errors.3f 来自: http : //wiki.bitnami.org/Components/Apache#How_to_debug_errors.3f
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.