gpt4 book ai didi

python - Google 应用程序引擎端点 api python

转载 作者:太空宇宙 更新时间:2023-11-03 16:20:12 25 4
gpt4 key购买 nike

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

这是代码:

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

enter image description here

enter image description here

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

如有任何帮助,我们将不胜感激。

最佳答案

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

关于python - Google 应用程序引擎端点 api python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38555353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com