无法确定API请求的URL(Google App Engine上的Python API)

2024-09-29 01:35:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个非常简单的pythonapi,由googleappengine提供服务。我遇到的唯一问题是,我似乎无法弄清楚要到达特定端点方法的URL是什么。我收到一个404-找不到。你知道吗

我正在尝试在Android中使用这个API。目前,我有一个异步任务,似乎是正常运作,除了它没有达到正确的网址。你知道吗

有人知道我如何找到正确的网址吗?

更新:

我正在使用API的资源管理器,并注意到它正在使用这个URL

https://caramel-theory-800.appspot.com/_ah/api/photoswap/v1/user

我将尝试在Android中使用它,但是我没有看到任何与我使用的方法相关的东西。你知道吗

附录yaml

application: caramel-theory-800
version: 1
runtime: python27
threadsafe: true
api_version: 1

handlers:
# Endpoints handler
- url: /_ah/spi/.*
  script: photoswap_api.APPLICATION

libraries:
- name: pycrypto
  version: latest
- name: endpoints
  version: 1.0

照片_api.py公司

@endpoints.api(name='photoswap', version='v1')
class PhotoswapAPI(remote.Service):
    @endpoints.method(UserCreateRequestMessage, UserCreateResponseMessage,
                      path='user', http_method='POST',
                      name='user.create')
    def user_create(self, request):
        entity = User(email=request.email, password=request.password, username=request.username)
        entity.put()
        return UserCreateResponseMessage(email=entity.email, password=entity.password, username=entity.username,
                                         id=entity.key.id())


APPLICATION = endpoints.api_server([PhotoswapAPI], restricted=False)

Tags: 方法nameapiurlversionemailrequestusername