Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用金字塔构建web服务_Python_Web Services_Pyramid - Fatal编程技术网

Python 使用金字塔构建web服务

Python 使用金字塔构建web服务,python,web-services,pyramid,Python,Web Services,Pyramid,我是一个初学者,试图学习如何使用金字塔web框架构建RESTful web服务。我熟悉Web服务的基础知识,并且有使用Java构建Web服务的经验。我计划不使用像Cornice这样的web服务构建器。 在路线配置中是否有任何特定的内容需要添加? 有人能告诉我从哪里开始,或者给我一些有用的链接来学习用金字塔构建web服务吗 我如何知道传递的是什么请求方法?在我的查询字符串中提到了它吗?@Tania-我认为从每个方法内部都可以调用self.request.method。但是,每个方法只有在与特定值匹

我是一个初学者,试图学习如何使用金字塔web框架构建RESTful web服务。我熟悉Web服务的基础知识,并且有使用Java构建Web服务的经验。我计划不使用像Cornice这样的web服务构建器。 在路线配置中是否有任何特定的内容需要添加?
有人能告诉我从哪里开始,或者给我一些有用的链接来学习用金字塔构建web服务吗

我如何知道传递的是什么请求方法?在我的查询字符串中提到了它吗?@Tania-我认为从每个方法内部都可以调用
self.request.method
。但是,每个方法只有在与特定值匹配时才被调用,因此再次查看它没有多大意义(即
get
方法只有在
self.request.method=='get'
时才被调用)。我如何知道传递的是什么请求方法?在我的查询字符串中提到了它吗?@Tania-我认为从每个方法内部都可以调用
self.request.method
。但是,每个方法只有在与特定值匹配时才被调用,因此再次查看它没有多大意义(即
get
方法只有在
self.request.method==“get”
时才被调用)
@view_defaults(route_name='myservice')
class MyServiceView(object):

    def __init__(self, request):
        self.request = request

    @view_config(request_method='GET')
    def get(self):
        return Response(u'This is the GET view')

    @view_config(request_method='POST')
    def post(self):
        return Response(u'This is the POST view')

    @view_config(request_method='PUT')
    def put(self):
        return Response(u'This is the PUT view')

    @view_config(request_method='DELETE')
    def delete(self):
        return Response(u'This is the DELETE view')