Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 672 Bytes
import djng
class RestView(object):
def __call__(self, request, *args, **kwargs):
method = request.method.upper()
if hasattr(self, method):
return getattr(self, method)(request, *args, **kwargs)
return self.method_not_supported(request)
def method_not_supported(request):
return djng.Response('Method not supported')
class MyView(RestView):
def GET(request):
return djng.Response('This is a GET')
def POST(request):
return djng.Response('This is a POST')
if __name__ == '__main__':
djng.serve(MyView(), '', 8888)
Something went wrong with that request. Please try again.