是否可能仅使用Google App Engine上的webapp2和Python创建API?
例如,假设我的路由/post/123
由此RequestHandler处理:
class ShowPosts(webapp2.RequestHandler):
def get(self):
posts = Post.query().fetch()
# return the post as data (JSON) here as response
当客户端向
/post/123
发起restful请求时,可以返回数据对象(而不是呈现的HTML页面)。这种做法是否可行或值得推荐?