{"id":16889660,"url":"https://github.com/benoitc/dj-webmachine","last_synced_at":"2025-03-17T06:31:45.619Z","repository":{"id":1090744,"uuid":"945014","full_name":"benoitc/dj-webmachine","owner":"benoitc","description":"Django REST layer","archived":false,"fork":false,"pushed_at":"2016-01-29T11:06:41.000Z","size":773,"stargazers_count":59,"open_issues_count":6,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-11T10:17:45.885Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://benoitc.github.com/dj-webmachine","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitc.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-09-28T09:04:06.000Z","updated_at":"2021-03-30T19:06:24.000Z","dependencies_parsed_at":"2022-07-15T07:17:25.249Z","dependency_job_id":null,"html_url":"https://github.com/benoitc/dj-webmachine","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdj-webmachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdj-webmachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdj-webmachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fdj-webmachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitc","download_url":"https://codeload.github.com/benoitc/dj-webmachine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847062,"owners_count":20357317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T16:58:12.018Z","updated_at":"2025-03-17T06:31:44.675Z","avatar_url":"https://github.com/benoitc.png","language":"Python","readme":"dj-webmachine\n-------------\n\ndj-webmachine is an application layer that adds HTTP semantic awareness on \ntop of Django and provides a simple and clean way to connect that to\nyour applications' behavior. dj-webmachine also offers you the\npossibility to build simple API based on your model and the tools to\ncreate automatically docs and clients from it (work in progress).\n\ndj-webmachine is released under the MIT license. See the LICENSE\nfile for the complete license.\n\nCopyright (c) 2010 Benoit Chesneau \u003cbenoitc@e-engura.org\u003e\nCopyright 2010 (c) Hyperweek - http://hyperweek.net\n\n\nInstall\n+++++++\n\nMake sure that you have a working Python_ 2.x \u003e=2.5 installed and Django_ \u003e= 1.1.\n\n\nWith pip\n~~~~~~~~\n\n::\n    \n    $ pip install dj-webmachine\n\nFrom source\n~~~~~~~~~~~\n\nGet the dj-webmachine code::\n\n    $ git clone https://github.com/benoitc/dj-webmachine.git\n    $ cd dj-webmachine\n\nOr using a tarbal::\n\n    $ wget http://github.com/benoitc/dj-webmachine/tarball/master -o dj-webmachine.tar.gz\n    $ tar xvzf dj-webmachine.tar.gz\n    $ cd dj-webmachine-$HASH/\n\nand install::\n\n    $ sudo python setup.py install\n\n\ndj-webmachine in 5 minutes\n++++++++++++++++++++++++++\n\nWe will quickly create an Hello world accepting HTML and JSON.\n\n::\n\n    $ django-admin startproject helloworld\n    $ cd helloworld\n    $ python manage.py startapp hello\n\nIn the hello folder create a file named ``resources.py``::\n\n    import json\n    from webmachine import Resource\n    \n    class Hello(Resource):\n\n        def content_types_provided(self, req, resp):\n            \"\"\"\" define the content type we render accoridng the Accept\n            header.\n            \"\"\"\n            return ( \n                (\"\", self.to_html),\n                (\"application/json\", self.to_json)\n            )\n\n        def to_html(self, req, resp):\n            return \"\u003chtml\u003e\u003cbody\u003eHello world!\u003c/body\u003e\u003c/html\u003e\\n\"\n    \n        def to_json(self, req, resp):\n            return \"%s\\n\" % json.dumps({\"message\": \"hello world!\", \"ok\": True})\n    \nAdd **dj-webmachine** and your hello app to ``INSTALLED_APPS`` in your\nsettings::\n\n    INSTALLED_APPS = (\n        ...\n        'webmachine',\n        'helloworld.hello'\n    )\n\nPut your the Hello resource in your ``urls.py``::\n\n    from django.conf.urls.defaults import *\n\n    from helloworld.hello.resource import Hello\n\n    urlpatterns = patterns('',\n        (r'^$', Hello()),\n    )\n\nLaunch your application::\n\n    $ python manage.py runserver\n\nTake a look! Point a web browser at http://localhost:8000/\n\nOr with curl::\n\n    $ curl http://127.0.0.1:8000\n    \u003chtml\u003e\u003cbody\u003eHello world!\u003c/body\u003e\u003c/html\u003e\n\n    $ curl http://127.0.0.1:8000 -H \"Accept: application/json\"\n    {\"message\": \"hello world!\", \"ok\": true}    \n\n\n    \nThe first line ask the hello page as html while the second using the\nsame url ask for JSON. \n\nTo learn how to do more interresting things, checkout `some examples \u003chttp://benoitc.github.com/dj-webmachine/recipes.html\u003e`_ or read `more documentations \u003chttp://benoitc.github.com/dj-webmachine/docs.html\u003e`_ .\n\n.. _Python: http://python.org\n.. _Django: http://djangoproject.org\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fdj-webmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitc%2Fdj-webmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fdj-webmachine/lists"}