谷歌应用程序引擎端点api python

时间:2016-07-24 18:27:31

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

我在端点遇到问题。我在本地计算机上使用谷歌应用程序引擎。我正在尝试建立端点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)

ModelClasses.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

enter image description here

enter image description here

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

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

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

相关问题