mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-13 13:16:55 +03:00
Updated sandbox links
This commit is contained in:
parent
7d70948f9b
commit
00d3aa21ba
|
@ -370,7 +370,7 @@ class DocumentingTemplateRenderer(BaseRenderer):
|
||||||
class DocumentingHTMLRenderer(DocumentingTemplateRenderer):
|
class DocumentingHTMLRenderer(DocumentingTemplateRenderer):
|
||||||
"""
|
"""
|
||||||
Renderer which provides a browsable HTML interface for an API.
|
Renderer which provides a browsable HTML interface for an API.
|
||||||
See the examples at http://api.django-rest-framework.org to see this in action.
|
See the examples at http://shielded-mountain-6732.herokuapp.com to see this in action.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
media_type = 'text/html'
|
media_type = 'text/html'
|
||||||
|
|
|
@ -9,7 +9,7 @@ There are a few real world web API examples included with Django REST framework.
|
||||||
|
|
||||||
All the examples are freely available for testing in the sandbox:
|
All the examples are freely available for testing in the sandbox:
|
||||||
|
|
||||||
http://rest.ep.io
|
http://shielded-mountain-6732.herokuapp.com
|
||||||
|
|
||||||
(The :doc:`examples/sandbox` resource is also documented.)
|
(The :doc:`examples/sandbox` resource is also documented.)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Blog Posts API
|
Blog Posts API
|
||||||
==============
|
==============
|
||||||
|
|
||||||
* http://rest.ep.io/blog-post/
|
* http://shielded-mountain-6732.herokuapp.com/blog-post/
|
||||||
|
|
||||||
The models
|
The models
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -5,11 +5,11 @@ Getting Started - Model Views
|
||||||
|
|
||||||
A live sandbox instance of this API is available:
|
A live sandbox instance of this API is available:
|
||||||
|
|
||||||
http://rest.ep.io/model-resource-example/
|
http://shielded-mountain-6732.herokuapp.com/model-resource-example/
|
||||||
|
|
||||||
You can browse the API using a web browser, or from the command line::
|
You can browse the API using a web browser, or from the command line::
|
||||||
|
|
||||||
curl -X GET http://rest.ep.io/resource-example/ -H 'Accept: text/plain'
|
curl -X GET http://shielded-mountain-6732.herokuapp.com/resource-example/ -H 'Accept: text/plain'
|
||||||
|
|
||||||
Often you'll want parts of your API to directly map to existing django models. Django REST framework handles this nicely for you in a couple of ways:
|
Often you'll want parts of your API to directly map to existing django models. Django REST framework handles this nicely for you in a couple of ways:
|
||||||
|
|
||||||
|
@ -41,16 +41,16 @@ And we're done. We've now got a fully browseable API, which supports multiple i
|
||||||
|
|
||||||
We can visit the API in our browser:
|
We can visit the API in our browser:
|
||||||
|
|
||||||
* http://rest.ep.io/model-resource-example/
|
* http://shielded-mountain-6732.herokuapp.com/model-resource-example/
|
||||||
|
|
||||||
Or access it from the command line using curl:
|
Or access it from the command line using curl:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# Demonstrates API's input validation using form input
|
# Demonstrates API's input validation using form input
|
||||||
bash: curl -X POST --data 'foo=true' http://rest.ep.io/model-resource-example/
|
bash: curl -X POST --data 'foo=true' http://shielded-mountain-6732.herokuapp.com/model-resource-example/
|
||||||
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
||||||
|
|
||||||
# Demonstrates API's input validation using JSON input
|
# Demonstrates API's input validation using JSON input
|
||||||
bash: curl -X POST -H 'Content-Type: application/json' --data-binary '{"foo":true}' http://rest.ep.io/model-resource-example/
|
bash: curl -X POST -H 'Content-Type: application/json' --data-binary '{"foo":true}' http://shielded-mountain-6732.herokuapp.com/model-resource-example/
|
||||||
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Object Store API
|
Object Store API
|
||||||
================
|
================
|
||||||
|
|
||||||
* http://rest.ep.io/object-store/
|
* http://shielded-mountain-6732.herokuapp.com/object-store/
|
||||||
|
|
||||||
This example shows an object store API that can be used to store arbitrary serializable content.
|
This example shows an object store API that can be used to store arbitrary serializable content.
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ the example View below.:
|
||||||
The `IsAuthenticated` permission will only let a user do a 'GET' if he is authenticated. Try it
|
The `IsAuthenticated` permission will only let a user do a 'GET' if he is authenticated. Try it
|
||||||
yourself on the live sandbox__
|
yourself on the live sandbox__
|
||||||
|
|
||||||
__ http://rest.ep.io/permissions-example/loggedin
|
__ http://shielded-mountain-6732.herokuapp.com/permissions-example/loggedin
|
||||||
|
|
||||||
|
|
||||||
Throttling
|
Throttling
|
||||||
|
@ -53,7 +53,7 @@ may do on our view to 10 requests per minute.:
|
||||||
|
|
||||||
Try it yourself on the live sandbox__.
|
Try it yourself on the live sandbox__.
|
||||||
|
|
||||||
__ http://rest.ep.io/permissions-example/throttling
|
__ http://shielded-mountain-6732.herokuapp.com/permissions-example/throttling
|
||||||
|
|
||||||
Now if you want a view to require both aurhentication and throttling, you simply declare them
|
Now if you want a view to require both aurhentication and throttling, you simply declare them
|
||||||
both::
|
both::
|
||||||
|
|
|
@ -6,11 +6,11 @@ We're going to provide a simple wrapper around the awesome `pygments <http://pyg
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
A live sandbox instance of this API is available at http://rest.ep.io/pygments/
|
A live sandbox instance of this API is available at http://shielded-mountain-6732.herokuapp.com/pygments/
|
||||||
|
|
||||||
You can browse the API using a web browser, or from the command line::
|
You can browse the API using a web browser, or from the command line::
|
||||||
|
|
||||||
curl -X GET http://rest.ep.io/pygments/ -H 'Accept: text/plain'
|
curl -X GET http://shielded-mountain-6732.herokuapp.com/pygments/ -H 'Accept: text/plain'
|
||||||
|
|
||||||
|
|
||||||
URL configuration
|
URL configuration
|
||||||
|
@ -77,13 +77,13 @@ For example if we make a POST request using form input:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
bash: curl -X POST --data 'code=print "hello, world!"' --data 'style=foobar' -H 'X-Requested-With: XMLHttpRequest' http://rest.ep.io/pygments/
|
bash: curl -X POST --data 'code=print "hello, world!"' --data 'style=foobar' -H 'X-Requested-With: XMLHttpRequest' http://shielded-mountain-6732.herokuapp.com/pygments/
|
||||||
{"detail": {"style": ["Select a valid choice. foobar is not one of the available choices."], "lexer": ["This field is required."]}}
|
{"detail": {"style": ["Select a valid choice. foobar is not one of the available choices."], "lexer": ["This field is required."]}}
|
||||||
|
|
||||||
Or if we make the same request using JSON:
|
Or if we make the same request using JSON:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
bash: curl -X POST --data-binary '{"code":"print \"hello, world!\"", "style":"foobar"}' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' http://rest.ep.io/pygments/
|
bash: curl -X POST --data-binary '{"code":"print \"hello, world!\"", "style":"foobar"}' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' http://shielded-mountain-6732.herokuapp.com/pygments/
|
||||||
{"detail": {"style": ["Select a valid choice. foobar is not one of the available choices."], "lexer": ["This field is required."]}}
|
{"detail": {"style": ["Select a valid choice. foobar is not one of the available choices."], "lexer": ["This field is required."]}}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ Getting Started - Views
|
||||||
|
|
||||||
A live sandbox instance of this API is available:
|
A live sandbox instance of this API is available:
|
||||||
|
|
||||||
http://rest.ep.io/resource-example/
|
http://shielded-mountain-6732.herokuapp.com/resource-example/
|
||||||
|
|
||||||
You can browse the API using a web browser, or from the command line::
|
You can browse the API using a web browser, or from the command line::
|
||||||
|
|
||||||
curl -X GET http://rest.ep.io/resource-example/ -H 'Accept: text/plain'
|
curl -X GET http://shielded-mountain-6732.herokuapp.com/resource-example/ -H 'Accept: text/plain'
|
||||||
|
|
||||||
We're going to start off with a simple example, that demonstrates a few things:
|
We're going to start off with a simple example, that demonstrates a few things:
|
||||||
|
|
||||||
|
@ -41,16 +41,16 @@ Now we'll write our views. The first is a read only view that links to three in
|
||||||
|
|
||||||
That's us done. Our API now provides both programmatic access using JSON and XML, as well a nice browseable HTML view, so we can now access it both from the browser:
|
That's us done. Our API now provides both programmatic access using JSON and XML, as well a nice browseable HTML view, so we can now access it both from the browser:
|
||||||
|
|
||||||
* http://rest.ep.io/resource-example/
|
* http://shielded-mountain-6732.herokuapp.com/resource-example/
|
||||||
|
|
||||||
And from the command line:
|
And from the command line:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# Demonstrates API's input validation using form input
|
# Demonstrates API's input validation using form input
|
||||||
bash: curl -X POST --data 'foo=true' http://rest.ep.io/resource-example/1/
|
bash: curl -X POST --data 'foo=true' http://shielded-mountain-6732.herokuapp.com/resource-example/1/
|
||||||
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
||||||
|
|
||||||
# Demonstrates API's input validation using JSON input
|
# Demonstrates API's input validation using JSON input
|
||||||
bash: curl -X POST -H 'Content-Type: application/json' --data-binary '{"foo":true}' http://rest.ep.io/resource-example/1/
|
bash: curl -X POST -H 'Content-Type: application/json' --data-binary '{"foo":true}' http://shielded-mountain-6732.herokuapp.com/resource-example/1/
|
||||||
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
{"detail": {"bar": ["This field is required."], "baz": ["This field is required."]}}
|
||||||
|
|
|
@ -8,11 +8,11 @@ a browseable Web API, and much of the other goodness that Django REST framework
|
||||||
|
|
||||||
A live sandbox instance of this API is available for testing:
|
A live sandbox instance of this API is available for testing:
|
||||||
|
|
||||||
* http://rest.ep.io/mixin/
|
* http://shielded-mountain-6732.herokuapp.com/mixin/
|
||||||
|
|
||||||
You can browse the API using a web browser, or from the command line::
|
You can browse the API using a web browser, or from the command line::
|
||||||
|
|
||||||
curl -X GET http://rest.ep.io/mixin/
|
curl -X GET http://shielded-mountain-6732.herokuapp.com/mixin/
|
||||||
|
|
||||||
|
|
||||||
URL configuration
|
URL configuration
|
||||||
|
|
|
@ -11,11 +11,11 @@ Here's an example which does a 'GET' on the `model-resource` example
|
||||||
in the sandbox.::
|
in the sandbox.::
|
||||||
|
|
||||||
>>> import urllib2
|
>>> import urllib2
|
||||||
>>> r = urllib2.urlopen('htpp://rest.ep.io/model-resource-example')
|
>>> r = urllib2.urlopen('htpp://shielded-mountain-6732.herokuapp.com/model-resource-example')
|
||||||
>>> r.getcode() # Check if the response was ok
|
>>> r.getcode() # Check if the response was ok
|
||||||
200
|
200
|
||||||
>>> print r.read() # Examin the response itself
|
>>> print r.read() # Examin the response itself
|
||||||
[{"url": "http://rest.ep.io/model-resource-example/1/", "baz": "sdf", "foo": true, "bar": 123}]
|
[{"url": "http://shielded-mountain-6732.herokuapp.com/model-resource-example/1/", "baz": "sdf", "foo": true, "bar": 123}]
|
||||||
|
|
||||||
Using the 'POST' method
|
Using the 'POST' method
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -29,11 +29,11 @@ to send the current time as as a string value for our POST.::
|
||||||
|
|
||||||
Now use the `Request` class and specify the 'Content-type'::
|
Now use the `Request` class and specify the 'Content-type'::
|
||||||
|
|
||||||
>>> req = urllib2.Request('http://rest.ep.io/model-resource-example/', data=d, headers={'Content-Type':'application/x-www-form-urlencoded'})
|
>>> req = urllib2.Request('http://shielded-mountain-6732.herokuapp.com/model-resource-example/', data=d, headers={'Content-Type':'application/x-www-form-urlencoded'})
|
||||||
>>> resp = urllib2.urlopen(req)
|
>>> resp = urllib2.urlopen(req)
|
||||||
>>> resp.getcode()
|
>>> resp.getcode()
|
||||||
201
|
201
|
||||||
>>> resp.read()
|
>>> resp.read()
|
||||||
'{"url": "http://rest.ep.io/model-resource-example/4/", "baz": "Fri Dec 30 18:22:52 2011", "foo": false, "bar": 123}'
|
'{"url": "http://shielded-mountain-6732.herokuapp.com/model-resource-example/4/", "baz": "Fri Dec 30 18:22:52 2011", "foo": false, "bar": 123}'
|
||||||
|
|
||||||
That should get you started to write a client for your own api.
|
That should get you started to write a client for your own api.
|
||||||
|
|
|
@ -16,7 +16,7 @@ Django REST framework is a lightweight REST framework for Django, that aims to m
|
||||||
Features:
|
Features:
|
||||||
---------
|
---------
|
||||||
|
|
||||||
* Automatically provides an awesome Django admin style `browse-able self-documenting API <http://rest.ep.io>`_.
|
* Automatically provides an awesome Django admin style `browse-able self-documenting API <http://shielded-mountain-6732.herokuapp.com>`_.
|
||||||
* Clean, simple, views for Resources, using Django's new `class based views <http://docs.djangoproject.com/en/dev/topics/class-based-views/>`_.
|
* Clean, simple, views for Resources, using Django's new `class based views <http://docs.djangoproject.com/en/dev/topics/class-based-views/>`_.
|
||||||
* Support for ModelResources with out-of-the-box default implementations and input validation.
|
* Support for ModelResources with out-of-the-box default implementations and input validation.
|
||||||
* Pluggable :mod:`.parsers`, :mod:`renderers`, :mod:`authentication` and :mod:`permissions` - Easy to customise.
|
* Pluggable :mod:`.parsers`, :mod:`renderers`, :mod:`authentication` and :mod:`permissions` - Easy to customise.
|
||||||
|
|
|
@ -11,8 +11,8 @@ class Sandbox(View):
|
||||||
|
|
||||||
All the example APIs allow anonymous access, and can be navigated either through the browser or from the command line...
|
All the example APIs allow anonymous access, and can be navigated either through the browser or from the command line...
|
||||||
|
|
||||||
bash: curl -X GET http://api.django-rest-framework.org/ # (Use default renderer)
|
bash: curl -X GET http://shielded-mountain-6732.herokuapp.com/ # (Use default renderer)
|
||||||
bash: curl -X GET http://api.django-rest-framework.org/ -H 'Accept: text/plain' # (Use plaintext documentation renderer)
|
bash: curl -X GET http://shielded-mountain-6732.herokuapp.com/ -H 'Accept: text/plain' # (Use plaintext documentation renderer)
|
||||||
|
|
||||||
The examples provided:
|
The examples provided:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user