path.py 738 B

1234567891011121314151617181920212223242526272829303132333435
  1. from random import randint
  2. from .app import App
  3. from .model import Json, World, WorldQueries, WorldUpdates, Plaintext
  4. from .collection import FortuneCollection
  5. @App.path(model=Json, path='json')
  6. def get_json():
  7. return Json()
  8. @App.path(model=World, path='db')
  9. def get_random_world():
  10. return World[randint(1, 10000)]
  11. @App.path(model=WorldQueries, path='queries')
  12. def get_queries(queries):
  13. return WorldQueries(queries)
  14. @App.path(model=FortuneCollection, path='fortunes')
  15. def get_fortunes():
  16. return FortuneCollection()
  17. @App.path(model=WorldUpdates, path='updates')
  18. def get_updates(queries):
  19. return WorldUpdates(queries)
  20. @App.path(model=Plaintext, path='plaintext')
  21. def get_plaintext():
  22. return Plaintext()