PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/web/jsontool.py

https://bitbucket.org/prologic/circuits/
Python | 22 lines | 13 code | 8 blank | 1 comment | 0 complexity | c7d60170176170543f75c31620f051f6 MD5 | raw file
  1. #!/usr/bin/env python
  2. from json import dumps
  3. from circuits.web import Server, Controller
  4. def json(f):
  5. def wrapper(self, *args, **kwargs):
  6. return dumps(f(self, *args, **kwargs))
  7. return wrapper
  8. class Root(Controller):
  9. @json
  10. def getrange(self, limit=4):
  11. return list(range(int(limit)))
  12. app = Server(("0.0.0.0", 8000))
  13. Root().register(app)
  14. app.run()