【问题标题】:Google app engine endpoints api python谷歌应用引擎端点 api python
【发布时间】:2016-11-28 01:31:48
【问题描述】:

我在端点中遇到问题。我在本地机器上使用谷歌应用引擎。我正在尝试制作一个端点 api。 api 已成功创建,但是当我打开资源管理器并选择我的 api 时,会为其提供一些参数。它不返回响应。作为回应,它说找不到 404

代码如下:

api.py

import endpoints
import protorpc

from ModelClasses import test


import main

@endpoints.api(name="test",version="v1",description="testingapi",hostname="login-test-1208.appspot.com")
class testapi(protorpc.remote.Service):



    @test.method(name="userinsert",path="userinsert",http_method="POST")
    def userinsert(self,request):

        qr = test()
        qr.user = request.user
        qr.passw = request.passw

        qr.put()
        return qr


app = endpoints.api_server([testapi],restricted=False)

模型类.py

from endpoints_proto_datastore.ndb import EndpointsModel
from google.appengine.ext import ndb



class test(EndpointsModel):

    user = ndb.StringProperty(required=True)
    passw = ndb.StringProperty(required=True)

app.yaml

application: ID
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico


- url: /static
  static_dir: static

- url: /stylesheets
  static_dir: stylesheets

- url: /(.*\.js)
  mime_type: text/javascript
  static_files: static/\1
  upload: static/(.*\.js)


- url: /_ah/spi/.*
  script: api.app

libraries:
- name: webapp2
  version: latest
- name: jinja2
  version: latest

- name: endpoints
  version: latest

- name: pycrypto
  version: 1.0

您可以在图片中看到请求和响应。

任何帮助将不胜感激。

【问题讨论】:

  • 澄清一下:您是在测试在 localhost 上运行的 API,还是已经将 API 部署到 App Engine?如果在 localhost 上运行,您应该删除无论如何都是可选的hostname 参数,以确保请求实际发送到 localhost。
  • 感谢您的回复,我正在本地主机上运行它。
  • 它现在正在给我回复。但它说“503 服务不可用”。
  • 我发现了我的问题,现在一切正常,谢谢 :)

标签: python google-app-engine google-cloud-endpoints webapp2


【解决方案1】:

@Scarygami 回答是正确的。我必须删除主机名,因为我在本地主机上使用它。

【讨论】:

  • 我不相信你应该再需要主机名了。
猜你喜欢
  • 1970-01-01
  • 2017-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-11
  • 2014-07-20
  • 2011-08-21
相关资源
最近更新 更多