README.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ==============================
  2. Example Celery->HTTP Gateway
  3. ==============================
  4. This is an example service exposing the ability to apply tasks and query
  5. statuses/results over HTTP.
  6. Some familiarity with Django is recommended.
  7. `settings.py` contains the celery settings, you probably want to configure
  8. at least the broker related settings.
  9. To run the service you have to run the following commands::
  10. $ python manage.py syncdb # (if running the database backend)
  11. $ python manage.py runserver
  12. The service is now running at http://localhost:8000
  13. You can apply tasks, with the `/apply/<task_name>` URL::
  14. $ curl http://localhost:8000/apply/celery.ping/
  15. {"ok": "true", "task_id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}
  16. Then you can use the resulting task-id to get the return value::
  17. $ curl http://localhost:8000/e3a95109-afcd-4e54-a341-16c18fddf64b/status/
  18. {"task": {"status": "SUCCESS", "result": "pong", "id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}}
  19. If you don't want to expose all tasks there're a few possible
  20. approaches. For instance you can extend the `apply` view to only
  21. accept a white-list. Another possibility is to just make views for every task you want to
  22. expose. We made on such view for ping in `views.ping`::
  23. $ curl http://localhost:8000/ping/
  24. {"ok": "true", "task_id": "383c902c-ba07-436b-b0f3-ea09cc22107c"}