我在应用引擎上的谷歌云端点获得了404

时间:2022-08-22 11:20:14

In my app, the app.yaml (the relevant part) looks like this:

在我的应用程序中,app.yaml(相关部分)看起来像这样:

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

- url: /logs
  script: logviewer.main.app

- url: /static
  static_dir: static

- url: /(.*\.html)
  static_files: pages/\1
  upload: pages/(.*\.html)

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

- url: .*
  script: main.app

I've included all handlers, just to make sure, but I'm quite certain that app.yml isn't the problem.

我已经包含了所有处理程序,只是为了确保,但我很确定app.yml不是问题所在。

The relevant part of api.py

api.py的相关部分

@endpoints.api(name='quizservice',version='v01',
               description='api backand for quickbuzzer')
class QuizService(remote.Service):


  @endpoints.method(messages.VoidMessage , messages.CreateQuizResponse, name="createQuiz")
  def createQuiz(self, request):
    . . .

application = endpoints.api_server([QuizService],
                                restricted=False)

Now, when I visit the explorer and try running the QuiizService.createQuiz method, I get a 404 back.

现在,当我访问资源管理器并尝试运行QuiizService.createQuiz方法时,我得到了404。

Looking at the logs, I see this:

看着日志,我看到了这个:

INFO     2013-04-29 17:53:15,560 server.py:561] default: "GET /_ah/api/discovery/v1/apis/quizservice/v01/rest HTTP/1.1" 200 2738
INFO     2013-04-29 17:53:22,118 server.py:561] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 1585
WARNING  2013-04-29 17:53:22,119 api_config_manager.py:201] No endpoint found for path: quizservice/v01
INFO     2013-04-29 17:53:22,119 server.py:561] default: "POST /_ah/api/quizservice/v01 HTTP/1.1" 404 9

2 个解决方案

#1


3  

I was able to solve the issue by supplying a path parameter to the endpoints.method decorator. What I'm wondering now, is if the endpoints api could choose a default path based on my method name.

我能够通过向endpoints.method装饰器提供路径参数来解决问题。我现在想知道的是,端点api是否可以根据我的方法名称选择默认路径。

#2


1  

Another case where this error can be thrown is with incorrect order of url handlers declaration. See https://*.com/a/15675839/362953

可以抛出此错误的另一种情况是url处理程序声明的顺序不正确。请参阅https://*.com/a/15675839/362953

- url: .*
  script: main.app

Should come at the end, not before

应该到最后,而不是之前

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

In this case of OP the order is correct.

在OP的这种情况下,订单是正确的。

#1


3  

I was able to solve the issue by supplying a path parameter to the endpoints.method decorator. What I'm wondering now, is if the endpoints api could choose a default path based on my method name.

我能够通过向endpoints.method装饰器提供路径参数来解决问题。我现在想知道的是,端点api是否可以根据我的方法名称选择默认路径。

#2


1  

Another case where this error can be thrown is with incorrect order of url handlers declaration. See https://*.com/a/15675839/362953

可以抛出此错误的另一种情况是url处理程序声明的顺序不正确。请参阅https://*.com/a/15675839/362953

- url: .*
  script: main.app

Should come at the end, not before

应该到最后,而不是之前

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

In this case of OP the order is correct.

在OP的这种情况下,订单是正确的。