开发者

How to control Apache via Django to connect to mongoose(another HTTP server)?

I have been doing lots of searching and reading to solve this. The main goal is let a Django-based web management system connecting to a device which runs a http server as well. Django will handle user request and ask device for the re开发者_Go百科al data, then feedback to user.

Now I have a "kinda-work-in-concept" solution:

  1. Browser -> Apache Server: Browser have jQuery and HTML/CSS to collect user request.

  2. Apache Server-> Device HTTP Server:

Apache + mod_python(or somesay Apache + mod_wsgi?) , so I might control the Apache to do stuff like build up a session and cookies to record login. But, this is the issue actually bugs me. How to make it work? Using what to build up socket connection between this two servers?


You could use httplib or urllib2 (both supplied in the Python standard library) in your Django view to send HTTP requests to the device running mongoose.

Alternatively you could use the Requests library which provides a less verbose API for generating HTTP requests - see also this blog post.

(Also, I would strongly recommend that you use mod_wsgi rather than mod_python as mod_wsgi is being actively maintained and performs better than mod_python, which was last updated in 2007)


If you have control over what runs on the device side, consider using XML-RPC to talk from client to server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜