小编Amb*_*oos的帖子

在多个类和多个文件上拆分Cloud Endpoint API

我已经开始使用Cloud Endpoint API作为首次使用Python的程序员(具有Java和PHP经验).

我想将所有内容保存在一个API中,但将不同的资源调用分成不同的文件.文档以此为例:

an_api = endpoints.api(name='library', version='v1.0')

@an_api.api_class(resource_name='shelves')
class Shelves(remote.Service):
   ...

@an_api.api_class(resource_name='books', path='books')
class Books(remote.Service):
   ...

endpoints.api_server([an_api])
Run Code Online (Sandbox Code Playgroud)

我想做的是把ShelvesBook类放在不同的文件中,因为它们都会变得很长.我试过移动它们,但这导致了一个空的API发现文档,因为API启动时可能没有加载/运行/解释文件.

我怎样才能解决这个问题?我觉得它会有所作为,import但我无法弄明白......

谢谢!

python google-app-engine google-cloud-endpoints

2
推荐指数
1
解决办法
908
查看次数