Starting a Local Server Video Lecture Transcript This transcript was automatically generated by Zoom, so there may be discrepancies between the video and the text. 17:15:08 Hi! Everybody! Welcome! Back! In this video. We're gonna take a quick detour from learning about d 3 js, to talk about how you can start a local server using python. 17:15:20 So in order to run some of our d. 3 Js examples, we are going to need to start a local server. 17:15:26 So this local server is just going to allow your code to make sure that it can go and navigate through your computer to find the data files that will be using. 17:15:37 So this is something that's built into a lot of these browsers for security reasons. 17:15:42 But by starting up a local server, a server running on your computer in the background, you'll be able to make sure that when I reference a file within my computer that you'll be able, you know D. 17:15:56 3 J. S. Will be able to navigate through your computer to get to it. 17:16:03 That you'll be able, to be done with python in a terminal or a command prompt. So a Mac in Linux will be using probably what's known as a terminal, and then windows you'll be looking for your command prompt so in order to start a local 17:16:14 server once you're in your terminal or command prompt, you need to first open it, get it open and running, then navigate to the Directory, storing the desired HTML. 17:16:24 Files. So for us, that's going to be the data, viz. 17:16:28 Repository, you run the following code, chunk, Pipyon, M. 17:16:34 Http. Server. 8,000. So this python is assuming that you're default. Python is python 3. 17:16:40 If it's not python 3, you might want to do python 3. 17:16:44 So if this doesn't work, Tryython 3 instead of python, then once you have roughly python 3 instead of python, then once you have run this, you're gonna run http Colon Slash Slash just copy, this and then open it and 17:16:56 whatever your web, browser of choices. And then you can navigate to whatever file you wanna open. 17:17:02 Open it, and then, when you're all done with everything running in the server. 17:17:06 You can hit for Max. Command C to close out for windows, connect C. 17:17:13 To close out for windows. Control C to close the server. 17:17:14 I don't know what the command is for Linux. 17:17:16 So Linux people, you'll have to figure out whatever the equivalent of these 2 is for you. All right. 17:17:22 So why don't we go ahead and try that? And in order to do so, I'm gonna cheat a little and copy and paste this so I don't have to remember it. 17:17:29 And then let's go to our terminal, which I've already opened up. 17:17:36 You can see here that I'm in the data vis repository. 17:17:40 So I'm gonna copy python dash M. Http. 17:17:45 Server 8,000. I hit enter, and now you can see when you see something like this. 17:17:49 This means that you now are running a hepertext. 17:17:53 Something, protocol. Uhhuh. I forget what it stands for exactly on your in your computer at this port. 17:18:01 And so now I've copied that, and I'm gonna go over to my Firefox browser. 17:18:06 Put it in the Browser address line and hit enter, and now we should, if you got this running correctly and you are in the data vis repository. 17:18:16 It should look something like this. Okay? And so then all I have to do is I'm gonna go to my lectures. 17:18:23 Web browser, and then, as an example, we could go to. 17:18:30 Here as an example, you can see. Now I'm running this, and this is something we'll learn how to use and create. 17:18:38 And just a few several lectures, a little bit more than a few, but several lectures will learn how to make this. 17:18:43 Okay, so that's the way we do it. And now let's say we're all done. 17:18:48 So I'm gonna hit X to close that out. Go back to my terminal and hit command or control. 17:18:55 C, so even with windows, it should be control. C, so even with Mac it should be control. C. 17:19:04 And I'll make sure your version of the slides are corrected and then you're all done, and so we could go back, and if we wanted to we could go back. 17:19:14 And now you can see that nothing's running there, because the server has been closed. 17:19:18 Okay, so this is important for examples. When we are trying to run. 17:19:27 D, 3 dot. Js, code that references data sets within our computer. 17:19:31 It's not necessary for every piece of HTML. 17:19:35 Code we're in you're running a Javascript just that allows you to navigate through your computer. 17:19:40 Okay, so that's it for this video. Now, you know how to start a local server to be consistent. 17:19:46 All of our remaining videos will be running. I will be running a local server and accessing the files that way. 17:19:53 You're welcome to if you don't want to run a local server, you're welcome to do that on the ones that don't need it. 17:19:58 But there will be files that possibly need a local server depending on what web browser you're using. 17:20:04 Okay, so that's it for this video. I hope to see you next time.