Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Python Requests library be used on Google App Engine?

Can I use Requests on Google App Engine? I think this library is perfect to create a REST client.

like image 785
Dilvane Zanardine Avatar asked Mar 07 '12 15:03

Dilvane Zanardine


People also ask

Is Python used in App Engine?

App Engine offers you a choice between two Python language environments.

What can you do with Python requests?

What can Requests do? Requests will allow you to send HTTP/1.1 requests using Python. With it, you can add content like headers, form data, multipart files, and parameters via simple Python libraries. It also allows you to access the response data of Python in the same way.


1 Answers

Install the requests-toolbelt library: https://github.com/sigmavirus24/requests-toolbelt

For App Engine it could be something like: pip install requests-toolbelt -t lib

(See: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library)

Then add:

from requests_toolbelt.adapters import appengine appengine.monkeypatch() 

In your main.py or equivalent.

Edit: this solution is now part of the official documentation: https://cloud.google.com/appengine/docs/python/issue-requests#issuing_an_http_request (in the REQUESTS tab)

like image 99
Eyal Levin Avatar answered Sep 22 '22 05:09

Eyal Levin