本文介绍了使用Python客户端来使用GAE端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google AppEngine端点来构建Web API。
我将用一个用Python编写的客户端来使用它。
我知道提供脚本来生成Android和iOS客户端API,但似乎并没有任何可比的Python。



看起来确实如此重复编码一切。例如,消息定义基本上是相同的。



无论如何,这样做更容易吗?



感谢您可以使用,它与端点兼容。



通常情况下,您会使用 service = build(api,version,http = http)例如 service = build(plus,v1,http = http)

为使用您的端点库,您可以使用:
$ b $
创建一个客户端以访问Google+ API。 b

  service = build(your_api,your_api_version,http = http,
discoveryServiceUrl =(https://yourapp.appspot.com/_ah/api / discovery / v1 /
apis / {api} / {apiVersion} / rest))

然后,您可以使用

  result = serv ice.resource()。method([parameters])。execute()


I am using Google AppEngine Endpoints to build a web API.I will consume it with a client written in Python.I know that scripts are provided to generate Android and iOS client API, but it doesn't seem that there is anything comparable for Python.

It does seem redundant to code everything again. For instance, the messages definition which are basically the same.

It there anyway of getting this done more easily?

Thanks

解决方案

You can use the Google APIs Client Library for Python which is compatible with endpoints.

Normally you would build a client using service = build(api, version, http=http) for example service = build("plus", "v1", http=http) to build a client to access to Google+ API.

For using the library for your endpoint you would use:

service = build("your_api", "your_api_version", http=http,
  discoveryServiceUrl=("https://yourapp.appspot.com/_ah/api/discovery/v1/"
                       "apis/{api}/{apiVersion}/rest"))

You can then access your API with

result = service.resource().method([parameters]).execute()

这篇关于使用Python客户端来使用GAE端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:55