diff options
| author | Richard Wackerbarth | 2013-01-09 11:19:12 -0600 | 
|---|---|---|
| committer | Richard Wackerbarth | 2013-01-10 15:37:49 -0600 | 
| commit | 12efd78fcf40ea8acf95259ffc5269bd9f360d2f (patch) | |
| tree | 374c02df58418f9db6d9d5c30552f9d2710625e2 /docs | |
| parent | 8efd9563a6d207619ebbd066292fa910023189ae (diff) | |
| download | django-rest-framework-12efd78fcf40ea8acf95259ffc5269bd9f360d2f.tar.bz2 | |
Bringing up the Web API
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/tutorial/1-serialization.md | 33 | 
1 files changed, 31 insertions, 2 deletions
diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index d12f7935..28aaea4d 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -295,9 +295,38 @@ It's worth noting that there are a couple of edge cases we're not dealing with p  ## Testing our first attempt at a Web API -**TODO: Describe using runserver and making example requests from console** +Now we can start up a sample server that serves our snippets. -**TODO: Describe opening in a web browser and viewing json output** +Quit out of the shell + +	quit() + +and start up Django's development server + +	python manage.py runserver + +	Validating models... + +	0 errors found +	Django version 1.4.3, using settings 'tutorial.settings' +	Development server is running at http://127.0.0.1:8000/ +	Quit the server with CONTROL-C. + +In another terminal window, we can test the server. + +We can get a list of all of the snippets (we only have one at the moment) + +	curl http://127.0.0.1:8000/snippets/ + +	[{"id": 1, "title": "", "code": "print \"hello, world\"\n", "linenos": false, "language": "python", "style": "friendly"}] + +or we can get a particular snippet by referencing its id + +	curl http://127.0.0.1:8000/snippets/1/ + +	{"id": 1, "title": "", "code": "print \"hello, world\"\n", "linenos": false, "language": "python", "style": "friendly"} + +Similarly, you can have the same json displayed by referencing these URLs from your favorite web browser.  ## Where are we now  | 
