Google应用程序引擎端点api python
我在终点站面临一个问题。我在本地机器上使用谷歌应用程序引擎。我正在尝试创建一个端点api。api已成功创建,但当我打开资源管理器并选择我的api时,请为其提供一些参数。它不返回响应。作为回应,它说404没有找到 代码如下: api.pyGoogle应用程序引擎端点api python,python,google-app-engine,google-cloud-endpoints,webapp2,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=
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
您可以在图片中看到请求和响应
任何帮助都将不胜感激。@Scarygami Answere是正确的。我必须删除主机名,因为我正在本地主机上使用它。只是想澄清一下:您是在本地主机上测试API,还是已经将API部署到App Engine?如果在localhost上运行,您应该删除可选的
hostname
参数,以确保请求实际发送到localhost。感谢您的响应我正在localhost上运行它。它现在正在给我响应。但它说的是“503服务不可用”。我解决了我的问题,现在它工作得很好。谢谢:)我认为你不应该再需要主机名了。