In this section we're going to start working on the no J.S. web application.
If you're not familiar no J.S. or you don't know any javascript and you don't want to know any javascript
that is totally fine.
You can pause the video right now skip to the next section where I will have a text link for you to
download the two files that you're going to need so totally fine if you don't want to write any javascript
at all.
Otherwise stick around and we'll get started on this tiny web application so to get started I'm going
to first flip back over to my terminal.
You'll notice that I'm still inside of that read this image directory.
I'm going to go up one directory and then I'll make a new project folder and Louis will call this how
about simple web because it's going to be a rather simple straightforward web application.
I'll then change into that directory and then I'm going to again start up my code editor inside there.
Now a quick reminder I was able to use the code command right here because I've set up Visual Studio
code to be executed for my command line.
So if you don't have that set up totally fine.
All you really need to do right now is open up your code editor.
Based on that simple web directory that we just created then inside of here we're gonna create first
a file called package dot Jason inside this file.
We're gonna put together a little bit of configuration to describe how our node application is going
to work exactly.
I'm going to first begin by placing a set of curly braces and then inside there I'm going to place a
key wrapped in double quotes and the first section we're going to put together is gonna list out all
of the different dependencies that our application needs to run correctly.
Notice how I'm rapping the word dependencies inside of a set of double quotes.
I've got a colon afterwards and then I open up a cruelly brace object then inside that set of curly
braces.
I will put down another set of double quotes and I'm going to say that in order for application to work
correctly we need a copy of Express.
I'll then put down a colon and then for the version I'm just gonna put a star to say we can use any
version of express out there.
We don't care after that.
I'm then going to put a comma on this line right here and then I'll add in one more section.
This is going to be a section that we will call scripts and this will contain some of the different
scripts that you can run it to get our application up and running.
I'm going to open up another set of curly braces just like we did a second ago.
I'll put a set double quotes and we're gonna create a script called start anytime that someone runs
the start script.
We are going to execute node index dot J.S. like so this right here is going to be what ultimately starts
up our server and gets it running.
All right.
So that's it inside of the package Dot.
J some file so you have specified dependency and we've created a single script.
I'm not gonna make sure that I save the file and then I'm going to close it and create a second file
inside the same directory.
And the second file I will call index dot J.S. so inside of here we're gonna first begin by requiring
in the Express library that we just marked as a dependency
or then use the Express library to create a new app like so.
And then we're we are going to set up one single root handler.
We're gonna say app dot get I'll pass in a string with a forward slash as a second argument I'll pass
in an arrow function that gets called with a request in response object and open up a function body
after placing a function arrow then inside of here we'll do resort sent and we're gonna send back a
message of Hi there.
So now anytime someone visits the root root of our application we are going to immediately send back
a string that says simply Hi there.
And so ultimately when we run our application my expectation is that in the browser we should be able
to visit this running web application and see Hi there.
Up here on the screen now the last thing we have to do is set up our application to listen on a port
Sudan at the bottom of the file.
I'll say app dot listen and I'll specify the port that we are going to be listening to as 80 80 as a
second argument I'll pass in an arrow function like so.
And then finally after the app starts listening to this port correctly we will print out a little message
that says listening on port 80 80 like so and then I'm going to make sure that I save this file.
All right so that's pretty much it.
We've got our package dot Chase on file that defined some configuration around our project and we've
got the index dot J file that contains the actual server logic.
So we're gonna take a quick pause right here.
When we come back the next section we're going to start talking about how we're going to put together
our darker file.
So quick break and I'll see you in just a minute.