RESTful and HTTP APIs in Pyramid Transcripts
Chapter: Customer Renderers
Lecture: Generating both CSV and JSON responses

Login or purchase this course to watch this video and the rest of the course contents.
0:01 So we've seen that we're getting csv back,
0:04 if we'd run this again, boom, there you go,
0:06 we have our csv data, we have the status,
0:09 here if you look at the headers you can see the content type is set along
0:12 with the character set, so we're definitely doing the exchange correctly.
0:15 Now, what if we wanted our json back,
0:19 here is some stuff, we'll get to that later,
0:23 so what if we want to say I am going to accept,
0:26 notice over here we can say csv, and we should get the same,
0:31 maybe we would like to be able to say json as well, send json,
0:36 alright, so we can come over here,
0:39 let's go back to our api, here,
0:44 and we can say accept type= text/ csv,
0:55 let's go over here and maybe make that csv, application/ json,
1:00 so I put json back, run it again, oh sorry that was supposed to be just accept,
1:05 okay, so now, let's try this again, first of all, let's go over here and say csv,
1:11 we should get the same, now if we put json, now we get json,
1:18 isn't that cool, here, let's do like this, accept csv, so turn this one off,
1:25 look at that, turn this one on, and we'll go back to json.
1:32 So you can see we have both of these renderers in play
1:34 in the next chapter what we are going to look at is
1:36 how to make this entirely controlled by the client
1:39 and have the server have nothing to do with it,
1:42 it will just render whatever it's supposed to render,
1:44 like whatever they ask for, but, for now, we'll have these two types,
1:48 because I want to still have the json option.