S
S
simplecode2012-09-27 13:28:48
Python
simplecode, 2012-09-27 13:28:48

HTTP request using CherryPy?

Hello!
There are two web applications in Python ( CherryPy ) on different servers.
It is necessary, having received a request from a user to one server, using CherryPy to change it and send it to another, then receive a response, change it and send it to the user.

import cherrypy
...
class Main(object):
    def index(self):
        # отправить http запрос
        # получить ответ
        # отправить ответ клиенту
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2012-10-07
@simplecode

To compose and process requests, I think it’s worth using pycurl or urllib2 - these are more low-level libraries or this library habrahabr.ru/post/127584/ Grab is a more convenient wrapper to use

g = Grab()
g.setup(post={'act': 'login', 'redirec_url': '', 'captcha': '', 'login': 'root', 'password': '123'}) # настраиваем параметры запроса
g.go('habrahabr.ru/ajax/auth/') # получаем ответ от сервера
#тут уже можно его изменять и отправлять

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question