无标题文章

一 View Callables
Defining a View Callable as a Function:

from pyramid.response import Response

def hello_world(request):
    return Response('Hello world!')

Defining a View Callable as a Class:

from pyramid.response import Response

class MyView(object):
    def __init__(self, request):
        self.request = request

    def __call__(self):
        return Response('hello')

你可能感兴趣的:(无标题文章)