1 00:00:07,790 --> 00:00:11,910 Hello and welcome to this edition to the way the programmer. 2 00:00:11,910 --> 00:00:14,670 So, my name's Charles Severance. 3 00:00:14,670 --> 00:00:16,020 I teach Python courses. 4 00:00:16,020 --> 00:00:17,565 I teach web vellum and courses. 5 00:00:17,565 --> 00:00:22,605 So, I was tasked with giving you a real-world example of object orientation. 6 00:00:22,605 --> 00:00:27,510 This is a little difficult for me because in the real world, 7 00:00:27,510 --> 00:00:31,140 little tiny programs tend to not 8 00:00:31,140 --> 00:00:35,610 cause us as programmers to build or even use objects in a sophisticated way. 9 00:00:35,610 --> 00:00:40,625 So, I've decided in this that I'm going to try to take you into 10 00:00:40,625 --> 00:00:45,350 a lot more complex world and give you a sense of what's going on behind 11 00:00:45,350 --> 00:00:50,225 the scenes and how object orientation is essential. 12 00:00:50,225 --> 00:00:54,815 So, I'm going to actually use Django which Django is a web development framework. 13 00:00:54,815 --> 00:00:58,790 This is less about writing Django than it is about looking at how 14 00:00:58,790 --> 00:01:02,870 Django uses objects to interact with you as a programmer who's going to write Django. 15 00:01:02,870 --> 00:01:06,915 So, if you really want to go crazy on this, 16 00:01:06,915 --> 00:01:09,385 go to my website dj4e.com, 17 00:01:09,385 --> 00:01:10,910 which is under construction. 18 00:01:10,910 --> 00:01:14,120 I'm not really teaching this course until a couple of months from now. 19 00:01:14,120 --> 00:01:17,270 But this will be eventually by the time you're watching this, 20 00:01:17,270 --> 00:01:19,865 maybe this'll be far more sophisticated. 21 00:01:19,865 --> 00:01:24,065 The thing I'm working through is what's called the Django tutorial. 22 00:01:24,065 --> 00:01:26,325 This comes from the Django community. 23 00:01:26,325 --> 00:01:29,400 This is where a lot of initial Django developers, they just say, 24 00:01:29,400 --> 00:01:30,780 "Hey, you want to get started, 25 00:01:30,780 --> 00:01:32,820 go ahead and get started." 26 00:01:32,820 --> 00:01:36,720 So, we're going to go through like the first one and two. 27 00:01:36,720 --> 00:01:38,220 But I've already done that. 28 00:01:38,220 --> 00:01:39,540 Again this is not about Django, 29 00:01:39,540 --> 00:01:40,910 this is about object orientation. 30 00:01:40,910 --> 00:01:44,180 So, I'm going to play with these things and show you some of the source code. 31 00:01:44,180 --> 00:01:46,490 So, it might be good if I showed you 32 00:01:46,490 --> 00:01:52,070 the eventual source code that I'm trying to weave a narrative that we get to. 33 00:01:52,070 --> 00:01:54,635 So, let's take a look at that source code. 34 00:01:54,635 --> 00:01:57,770 So, if I go into polls two, 35 00:01:57,770 --> 00:01:59,985 this is a little application. 36 00:01:59,985 --> 00:02:01,965 It doesn't do much. 37 00:02:01,965 --> 00:02:05,505 Right now it just prints out hello. 38 00:02:05,505 --> 00:02:08,620 I got to start the server, hang on. 39 00:02:18,830 --> 00:02:21,270 So, I have the server running. 40 00:02:21,270 --> 00:02:23,800 This little application. 41 00:02:27,860 --> 00:02:34,665 I got to go up a directory. Now, it's running. 42 00:02:34,665 --> 00:02:37,780 So, this little application that it's only at the second step of 43 00:02:37,780 --> 00:02:43,040 the tutorial and the only thing that it does is print something out. 44 00:02:43,040 --> 00:02:47,210 As such it's a not a very sophisticated application. 45 00:02:50,070 --> 00:02:52,840 I'm going to talk to you about three files. 46 00:02:52,840 --> 00:02:56,545 The first file is a file called the URLs file. 47 00:02:56,545 --> 00:03:00,475 The URLs file is very simple and it basically says, 48 00:03:00,475 --> 00:03:05,380 for this particular path which is the path that has nothing here after that slash, 49 00:03:05,380 --> 00:03:10,255 run this code from the file views with a method named index. 50 00:03:10,255 --> 00:03:12,395 So, if I look at views, 51 00:03:12,395 --> 00:03:14,430 this is the view code. 52 00:03:14,430 --> 00:03:16,030 It basically is saying, 53 00:03:16,030 --> 00:03:21,095 return an HTTP response because it's part of the request response cycle. 54 00:03:21,095 --> 00:03:24,900 Hello world and that prints this thing out. 55 00:03:24,900 --> 00:03:27,120 It's calling a bunch of things. 56 00:03:27,120 --> 00:03:30,080 Believe me and I'll show you a little bit at how tough this would be, 57 00:03:30,080 --> 00:03:33,260 if we didn't have Django doing all this work. 58 00:03:33,260 --> 00:03:35,590 So, this is the code that we have to write. 59 00:03:35,590 --> 00:03:38,240 Then the other thing that we're not going to cover too much 60 00:03:38,240 --> 00:03:40,745 about is how to create database tables. 61 00:03:40,745 --> 00:03:43,445 Here's this model file in this class. 62 00:03:43,445 --> 00:03:49,264 Basically, says let's make a question model which is also then a table in the database 63 00:03:49,264 --> 00:03:55,905 and that it is extending an object that comes from Django called models.model. 64 00:03:55,905 --> 00:03:58,910 If you look down, this is the code that I've got to do and 65 00:03:58,910 --> 00:04:01,690 it has the crates fields in the database and all these other things. 66 00:04:01,690 --> 00:04:04,120 If I took a look at what this database is, 67 00:04:04,120 --> 00:04:09,680 it ends up with all this other stuff and has all these files that are created for me. 68 00:04:09,680 --> 00:04:11,720 There's data in these files. 69 00:04:11,720 --> 00:04:14,735 I mean there's a structure in these files et cetera. 70 00:04:14,735 --> 00:04:17,700 All I did was, created this. 71 00:04:17,700 --> 00:04:21,290 So, there's a sort of a very small amount of work that I 72 00:04:21,290 --> 00:04:25,130 had to do to get Django to do a whole bunch of work for me. 73 00:04:25,130 --> 00:04:28,970 I do that by extending an object that I'm handed, 74 00:04:28,970 --> 00:04:32,845 this models.model object is something that I'm extending. 75 00:04:32,845 --> 00:04:35,160 So, at the end of the day, 76 00:04:35,160 --> 00:04:38,020 what I want to do is I want to look at what it takes to 77 00:04:38,020 --> 00:04:43,215 take a URL and have a piece of code that responds to that URL. 78 00:04:43,215 --> 00:04:45,100 So, here's some URLs. 79 00:04:45,100 --> 00:04:50,095 I want to show you how Django works and what Django gives you 80 00:04:50,095 --> 00:04:55,690 in a way that makes building Django code way more easier than it could be. 81 00:04:55,690 --> 00:04:58,180 So, if I was to build 82 00:04:58,180 --> 00:05:01,045 a web server and I've written here and I'll show you this code in a second. 83 00:05:01,045 --> 00:05:08,410 I've written the simplest raw Python web server that I could write. 84 00:05:08,410 --> 00:05:10,615 Basically, at some point, 85 00:05:10,615 --> 00:05:12,505 a browser's going to type the URL. 86 00:05:12,505 --> 00:05:15,460 It's going to send a request over the Internet to your computer. 87 00:05:15,460 --> 00:05:19,910 In that computer, there is like an operating system whether it's 88 00:05:19,910 --> 00:05:25,020 a Mac or a Windows or a Linux and it has networking capability TCP/ IP. 89 00:05:25,020 --> 00:05:27,230 There are documents that if you really wanted to, 90 00:05:27,230 --> 00:05:29,075 you would learn how to build those things. 91 00:05:29,075 --> 00:05:33,680 So, you can type into Google, RFC791 or RFC793. 92 00:05:33,680 --> 00:05:38,265 Then you can go get a sense of how hard that really would be. 93 00:05:38,265 --> 00:05:40,490 I don't know if you've played with sockets or not, 94 00:05:40,490 --> 00:05:43,940 but there is some socket or socket library inside of Python. 95 00:05:43,940 --> 00:05:48,680 Then we're going to create a very simple web server that's going to receive 96 00:05:48,680 --> 00:05:55,465 this request from the browser and then send back a really tiny little HTML bit. 97 00:05:55,465 --> 00:05:59,805 It's going to be sent back to that browser, very tiny HTML. 98 00:05:59,805 --> 00:06:01,650 Little body tag, Hello world, 99 00:06:01,650 --> 00:06:04,095 slash body, slash HTML. 100 00:06:04,095 --> 00:06:07,635 I'll cover all this stuff, how we create this server. 101 00:06:07,635 --> 00:06:11,220 This isn't eveb a real web servers, 102 00:06:11,220 --> 00:06:12,935 it's not reading files or anything else. 103 00:06:12,935 --> 00:06:18,135 It responds to every request with Hello world over and, over and over again. 104 00:06:18,135 --> 00:06:21,180 Then the next thing we're going to show after that is 105 00:06:21,180 --> 00:06:23,840 we're going to show how those three files that I showed you, 106 00:06:23,840 --> 00:06:27,410 models.py, URLs.py, and views.py. 107 00:06:27,410 --> 00:06:30,255 We write 25 lines of code. 108 00:06:30,255 --> 00:06:31,935 Then we've created this application. 109 00:06:31,935 --> 00:06:34,835 That's very sophisticated and it's very capable. 110 00:06:34,835 --> 00:06:40,250 Then after that, I'm going to show you sort of the detail of how within Django, 111 00:06:40,250 --> 00:06:43,610 Django creates objects that then you extend 112 00:06:43,610 --> 00:06:47,090 to communicate with Django how you want your application to work. 113 00:06:47,090 --> 00:06:51,305 So, we're going to start with a very low level concept 114 00:06:51,305 --> 00:06:57,110 of how a Python program would talk directly to a web browser. 115 00:06:57,110 --> 00:07:03,000 So, first let's take a look at this server code. 116 00:07:03,210 --> 00:07:07,085 Let me start a new browser, 117 00:07:07,085 --> 00:07:12,190 let me actually get rid of the Django server can stay there. 118 00:07:18,590 --> 00:07:23,020 You can download this from djquery.com, 119 00:07:23,020 --> 00:07:28,950 it's a little smaller so we can see it all. 120 00:07:29,190 --> 00:07:32,140 Okay, so if you were here, 121 00:07:32,140 --> 00:07:34,120 some stack overflows that I used, 122 00:07:34,120 --> 00:07:37,115 and some Python documentation that I use to figure all this stuff out. 123 00:07:37,115 --> 00:07:39,120 This is not particularly an object. 124 00:07:39,120 --> 00:07:42,880 This is a socket library that's built into Python already. 125 00:07:42,880 --> 00:07:49,325 And then if we take look, one more line. 126 00:07:49,325 --> 00:07:53,620 I have to put a try except around all that stuff. 127 00:07:53,620 --> 00:07:56,815 So we can call it, we're going to print. 128 00:07:56,815 --> 00:07:58,150 Here's how you go get this thing. 129 00:07:58,150 --> 00:08:00,640 We're going to call this to create server function, 130 00:08:00,640 --> 00:08:03,720 and server socket, we're telling it to start a socket, 131 00:08:03,720 --> 00:08:05,140 a sockets little different than a file. 132 00:08:05,140 --> 00:08:06,520 It's kind like a file handle, 133 00:08:06,520 --> 00:08:09,740 except that's two-way thing which you can both read and write to the same thing. 134 00:08:09,740 --> 00:08:13,540 It's you can write to a file because it's like two sides. 135 00:08:13,540 --> 00:08:15,705 If you have one application, 136 00:08:15,705 --> 00:08:18,790 and they're both connected via socket one side can write, 137 00:08:18,790 --> 00:08:20,785 and then the other side can read, 138 00:08:20,785 --> 00:08:22,950 and then the other side can right, and it comes back. 139 00:08:22,950 --> 00:08:25,070 So it's like, it's almost like two connections. 140 00:08:25,070 --> 00:08:27,395 A socket is a bidirectional, 141 00:08:27,395 --> 00:08:29,110 or a two-way connection. 142 00:08:29,110 --> 00:08:30,410 So we're starting a socket, 143 00:08:30,410 --> 00:08:35,430 this is the server side because in Django you're building the server side not a browser. 144 00:08:35,430 --> 00:08:38,090 Browser is the client side, this is the server side. 145 00:08:38,090 --> 00:08:41,030 We wrap this whole thing in a try except, 146 00:08:41,030 --> 00:08:44,239 because I need to close these sockets, 147 00:08:44,239 --> 00:08:45,750 if you're writing this code, 148 00:08:45,750 --> 00:08:47,805 took me about an hour to write this code, 149 00:08:47,805 --> 00:08:50,130 even after I found it on stack overflow. 150 00:08:50,130 --> 00:08:53,120 So you don't really want to write this. I'm glad it worked. 151 00:08:53,120 --> 00:08:54,575 You can look at it, you can play with it, 152 00:08:54,575 --> 00:08:56,640 but all it really is it's whole goal of 153 00:08:56,640 --> 00:09:00,020 this code is to prove to you that you don't want to write this code. 154 00:09:00,020 --> 00:09:01,915 And so I'll just walk through it. 155 00:09:01,915 --> 00:09:03,280 What we're doing is, 156 00:09:03,280 --> 00:09:06,440 we're going to be a server which means we're waiting for connections, 157 00:09:06,440 --> 00:09:08,315 and that's what serversocket.bind, 158 00:09:08,315 --> 00:09:11,169 says wait for connections on port 9,000, 159 00:09:11,169 --> 00:09:15,410 serversocket.listen five, that means up to five connections. 160 00:09:15,410 --> 00:09:18,155 Then this while loop basically says, 161 00:09:18,155 --> 00:09:22,015 accept the socket if the socket has arrived. 162 00:09:22,015 --> 00:09:25,865 So it'll actually stop here until a socket connection happens. 163 00:09:25,865 --> 00:09:28,330 So when a browser makes a connection to your server, 164 00:09:28,330 --> 00:09:29,810 it sits here well, 165 00:09:29,810 --> 00:09:32,920 it sits here until the browser makes a connection, and then it drives down, 166 00:09:32,920 --> 00:09:35,955 and it gets these two pieces of data which are a tuple, 167 00:09:35,955 --> 00:09:37,985 but it is just an assignment statement. 168 00:09:37,985 --> 00:09:39,850 Client socket address. 169 00:09:39,850 --> 00:09:42,265 The address of where what the browser's coming from, 170 00:09:42,265 --> 00:09:43,960 and the socket objects. 171 00:09:43,960 --> 00:09:45,040 So this is now an object. 172 00:09:45,040 --> 00:09:51,160 So client socket is an object that's populated by the statement. 173 00:09:51,160 --> 00:09:53,830 So if you were to read the HTTP protocol you would 174 00:09:53,830 --> 00:09:56,790 realize that the first thing that browsers are going to do is send us a command like get, 175 00:09:56,790 --> 00:09:59,245 or post with a URL that it's interested in. 176 00:09:59,245 --> 00:10:03,240 So we're going to read the first 5,000 characters from the browser, 177 00:10:03,240 --> 00:10:04,770 and then we're going to decode it. 178 00:10:04,770 --> 00:10:06,380 I'll split based on new lines, 179 00:10:06,380 --> 00:10:09,990 because it's actually a series of lines both the HTTP command, 180 00:10:09,990 --> 00:10:11,875 and then a series of header values. 181 00:10:11,875 --> 00:10:13,510 We're going to print the very first line which 182 00:10:13,510 --> 00:10:15,305 you're going to see how this works in a second. 183 00:10:15,305 --> 00:10:18,400 And then we know what the HTTP protocol is, 184 00:10:18,400 --> 00:10:23,800 so we're going just send back the simplest of HTTP pages which is a 200 OK, 185 00:10:23,800 --> 00:10:26,310 which says this is a valid document here you are. 186 00:10:26,310 --> 00:10:31,310 We're going to send back UTF8 html, and then a blank line. 187 00:10:31,310 --> 00:10:32,945 So here's the blank line right here. 188 00:10:32,945 --> 00:10:35,920 They're going to send the body with two new lines at the end. 189 00:10:35,920 --> 00:10:39,580 Of course because we're sending it outside of our world, 190 00:10:39,580 --> 00:10:41,150 we're going to do a data.encode, 191 00:10:41,150 --> 00:10:43,165 so that the UTF8, is properly sent. 192 00:10:43,165 --> 00:10:45,150 So we're going to receive UTF8, 193 00:10:45,150 --> 00:10:46,875 that's where this decode came in. 194 00:10:46,875 --> 00:10:48,720 The get request that comes into us, 195 00:10:48,720 --> 00:10:49,965 is going to be UTF8. 196 00:10:49,965 --> 00:10:53,795 Then we're going to send back a document that's also UTF8. 197 00:10:53,795 --> 00:10:57,030 That's also why I told it, it's UTF8, 198 00:10:57,030 --> 00:11:01,985 and then encode is what converts the unicode inside a Python into UTF8. 199 00:11:01,985 --> 00:11:03,590 And then we have to kind of shut it down, 200 00:11:03,590 --> 00:11:06,525 which the shutdown sort of sends all the data, 201 00:11:06,525 --> 00:11:07,840 make sure the data gets received, 202 00:11:07,840 --> 00:11:09,485 and then take the socket. 203 00:11:09,485 --> 00:11:11,160 Then we go back up to the top, 204 00:11:11,160 --> 00:11:12,480 and we wait for the next sockets. 205 00:11:12,480 --> 00:11:18,390 So that's each one of the URLs that gets retrieved is going to be handled. 206 00:11:18,390 --> 00:11:19,890 So if keyboard is apply, 207 00:11:19,890 --> 00:11:22,085 hit Control C or Control Z. 208 00:11:22,085 --> 00:11:24,825 It shuts down, but closes the socket turns out it 209 00:11:24,825 --> 00:11:28,365 takes a minute or two to be able to start it back up again unless you do it. 210 00:11:28,365 --> 00:11:30,710 Or if like you type in change in this 211 00:11:30,710 --> 00:11:32,940 you make a mistake you project yourself an exception, 212 00:11:32,940 --> 00:11:34,620 and we still want to close the socket, 213 00:11:34,620 --> 00:11:36,400 if we made a mistake inside here. 214 00:11:36,400 --> 00:11:38,730 That was really helpful for me because it took 215 00:11:38,730 --> 00:11:41,225 me a long time to get this code work, and it blew up a lot. 216 00:11:41,225 --> 00:11:46,420 So now it's not blowing up. So now let's run this. 217 00:11:46,420 --> 00:11:51,665 I can say Python three server.py. 218 00:11:51,665 --> 00:11:56,480 Now, we have the world's simplest Python server. 219 00:11:56,480 --> 00:11:58,865 So if I go into my browser, 220 00:11:58,865 --> 00:12:00,955 and I go to local host, 221 00:12:00,955 --> 00:12:04,980 localhost 9,000, that's the ports like an extension on a phone system. 222 00:12:04,980 --> 00:12:10,225 So localhost: 9,000, says connect localhost which is the same computer that I'm on, 223 00:12:10,225 --> 00:12:11,620 does not really leaving to the internet. 224 00:12:11,620 --> 00:12:13,630 That would be a normal domain name, 225 00:12:13,630 --> 00:12:16,650 : 9,000 says on 9,000, 226 00:12:16,650 --> 00:12:19,535 and my Django was running on 8,000, 227 00:12:19,535 --> 00:12:23,490 and my little mini Python server is running on 9,000. 228 00:12:23,490 --> 00:12:25,010 So I'm going to copy that. 229 00:12:25,010 --> 00:12:27,789 I'm going to go into Google Chrome. 230 00:12:27,789 --> 00:12:32,705 I'm going to turn on developer console, 231 00:12:32,705 --> 00:12:35,790 and then I am going to turn, 232 00:12:35,790 --> 00:12:37,075 and watch the network. 233 00:12:37,075 --> 00:12:40,210 Then I'm going to type in that URL. 234 00:12:40,210 --> 00:12:42,205 That's just junk. 235 00:12:42,205 --> 00:12:43,800 So we don't want that, I don't want that too. 236 00:12:43,800 --> 00:12:46,545 Someone hit enter. If all goes well. 237 00:12:46,545 --> 00:12:50,550 So it says hello world, 238 00:12:50,550 --> 00:12:53,085 see that, pretty awesome, after all that work. 239 00:12:53,085 --> 00:12:58,525 So what happens is you go down here you can see that, where is this I don't want to see. 240 00:12:58,525 --> 00:12:59,830 I don't want to see that. 241 00:12:59,830 --> 00:13:04,704 So we send a request to the localhost on port 9,000, 242 00:13:04,704 --> 00:13:06,850 we did a GET 200 OK. 243 00:13:06,850 --> 00:13:10,350 Remember our application said 200 OK, where is that was, 244 00:13:10,350 --> 00:13:13,030 see this 200 right there, 200 OK, 245 00:13:13,030 --> 00:13:15,890 was the status that our browser got back from our application. 246 00:13:15,890 --> 00:13:17,960 The response headers. 247 00:13:17,960 --> 00:13:22,865 The response headers said that this is a html document with a character said of UTF8. 248 00:13:22,865 --> 00:13:25,180 "Oh looking looking looking where you did that." 249 00:13:25,180 --> 00:13:29,175 We said that in our Python server.py code, 250 00:13:29,175 --> 00:13:33,040 and request headers, this is all that stuff. 251 00:13:33,040 --> 00:13:37,230 This is the browser telling us what kind of browser it is et cetera, et cetera. 252 00:13:37,230 --> 00:13:40,050 Where that shows up is, remember I did this split, 253 00:13:40,050 --> 00:13:42,225 by only showing pieces sub zero. 254 00:13:42,225 --> 00:13:43,950 I'm not showing you any of those things, 255 00:13:43,950 --> 00:13:49,790 but if you just were to print out this rd variable in your version of it, 256 00:13:50,030 --> 00:13:53,265 you would actually see all of those headers, 257 00:13:53,265 --> 00:13:56,540 and that's the HTTP request response cycle. 258 00:13:56,540 --> 00:14:01,275 That's like the simplest diversion of the HTTP request response cycle. 259 00:14:01,275 --> 00:14:04,370 Now, we take a look at this, we'll see that this is also 260 00:14:04,370 --> 00:14:08,050 retrieving the document favicon because it's trying to return the icon. 261 00:14:08,050 --> 00:14:09,960 That icon would show up right here, 262 00:14:09,960 --> 00:14:15,135 and our web servers is not smart enough to give back icons. 263 00:14:15,135 --> 00:14:17,820 It only says hello world to every single request, 264 00:14:17,820 --> 00:14:19,725 because it went around twice, 265 00:14:19,725 --> 00:14:21,990 it did this for the localhost, 266 00:14:21,990 --> 00:14:23,765 slash, and then favicon. 267 00:14:23,765 --> 00:14:26,970 It did it again, and it simply sent back a document. 268 00:14:26,970 --> 00:14:32,220 Now, after awhile we can say this char type it is image JPEG. 269 00:14:32,220 --> 00:14:33,840 Then we would have different body, 270 00:14:33,840 --> 00:14:36,440 and then we could send favicons back and forth. 271 00:14:36,440 --> 00:14:42,030 If you'll notice the prints out at this print statement right here. 272 00:14:42,340 --> 00:14:44,855 This print statement right here, 273 00:14:44,855 --> 00:14:48,290 prints out the GET request which is, 274 00:14:48,290 --> 00:14:51,295 this is the first request that corresponds to that localhost. 275 00:14:51,295 --> 00:14:55,579 This is the second request that corresponds to that favicon. 276 00:14:56,710 --> 00:14:58,885 So we got two requests, 277 00:14:58,885 --> 00:15:00,365 and then I'm going to blow this up, 278 00:15:00,365 --> 00:15:02,890 and that's when it's going to hit the keyboard interrupt. 279 00:15:02,890 --> 00:15:04,330 Then it's going to shut down, 280 00:15:04,330 --> 00:15:06,500 and then it's going to finish that. 281 00:15:06,500 --> 00:15:10,215 So that server.py was, 282 00:15:10,215 --> 00:15:12,850 how a web application works. 283 00:15:12,850 --> 00:15:15,750 But this is like such a tiny fraction. 284 00:15:15,750 --> 00:15:21,035 If you really want it to build a real live web application that had multiple files, 285 00:15:21,035 --> 00:15:23,495 and CSS, and images, and all that stuff. 286 00:15:23,495 --> 00:15:25,865 It gets harder, and then receiving data, 287 00:15:25,865 --> 00:15:27,895 there's parsing of the incoming data. 288 00:15:27,895 --> 00:15:33,425 If you google, like the RFC for HTTP, 289 00:15:33,425 --> 00:15:40,675 RFC stands for request for comments. 290 00:15:40,675 --> 00:15:45,265 You will find RFC 2616, Hypertext Transfer Protocol. 291 00:15:45,265 --> 00:15:48,350 That gives you some subset of 292 00:15:48,350 --> 00:15:53,115 how much information you need to know to write a web server, 293 00:15:53,115 --> 00:15:55,025 and to write a web browser. 294 00:15:55,025 --> 00:15:57,045 So I'll just start to skim down. 295 00:15:57,045 --> 00:16:00,660 We got hundreds of pages. 296 00:16:00,660 --> 00:16:04,635 That was just a table of contents goes down to 176. 297 00:16:04,635 --> 00:16:08,590 This is one of many documents that describes how that works. 298 00:16:08,590 --> 00:16:12,915 So it turns out that code that I wrote is not entirely compliant, 299 00:16:12,915 --> 00:16:16,200 is just barely good enough to do those most crude, 300 00:16:16,200 --> 00:16:17,600 and simple version of this. 301 00:16:17,600 --> 00:16:19,470 So there you can look at it, and you can play with that, 302 00:16:19,470 --> 00:16:21,490 you could add print statements et cetera, 303 00:16:21,490 --> 00:16:22,980 et cetera, et cetera. 304 00:16:22,980 --> 00:16:28,150 So if you are going to want to write an entire browser, 305 00:16:28,150 --> 00:16:31,930 you have to figure all these things out in Django like 306 00:16:31,930 --> 00:16:35,650 the 2616 Hypertext Transport Protocol. 307 00:16:35,650 --> 00:16:36,995 You'd have to write all this. 308 00:16:36,995 --> 00:16:39,400 There's all these other rules. 309 00:16:39,400 --> 00:16:41,550 So I think what I'll do is I'll stop now, 310 00:16:41,550 --> 00:16:47,945 and then coming back I'm going to show you how Django implements that exact same thing, 311 00:16:47,945 --> 00:16:51,845 but then how your code hooks into Django in a way, 312 00:16:51,845 --> 00:16:54,710 where you're using object oriented programming to hook 313 00:16:54,710 --> 00:16:57,540 to code into Django in the right places. 314 00:16:57,540 --> 00:17:00,580 So that the monocode that you have to write is really small, 315 00:17:00,580 --> 00:17:03,965 and the amount of documentation that you have to read is extremely small. 316 00:17:03,965 --> 00:17:06,330 Then someone inside Django had to read lots, 317 00:17:06,330 --> 00:17:09,120 and lots of things about how to make this stuff work. 318 00:17:09,120 --> 00:17:10,585 So when we come back, 319 00:17:10,585 --> 00:17:14,280 we'll talk a lot more about your relationship between the Django code, 320 00:17:14,280 --> 00:17:18,420 and your code, and how that relationship has done through object-oriented programming.