0:00
welcome to the second video
0:04
we have already created an access point
0:07
and now we will create a simple web
0:22
let's create a new project again and
0:24
give some random name to it
0:30
to protocols http server and select the
0:47
here is our main file
0:50
let's build this once
0:59
it has finished building
1:02
now we will copy the code from this one
1:06
let's copy the includes first
1:29
then we will copy this handler
1:35
and also this uri structure
1:40
we don't need to copy others as we will
1:43
create new ones in our code
1:46
we just need the structure of these
1:47
functions and this is why copying one of
1:55
we do need the 404 error handler
2:12
then we also need the start web server
2:14
function stop web server connect handler
2:17
and the disconnect handler
2:26
next we will copy the main function so
2:29
let's copy this definition
2:43
we also need to copy netfin it as the
2:45
flash in it is already there
3:08
now we will copy these 2 lines
3:17
we don't need to copy this web server
3:19
start as we will start it inside the
3:21
connect handler itself
3:23
so this is it for the copying part
3:30
now let's delete the project as we don't
3:41
some of these includes were already
3:43
there so i am going to delete those
4:02
we don't need the ethernet or the
4:04
examples or the crypto includes
4:14
let's build it once to check for the
4:33
there is some error due to tag
4:35
actually it should have been defined on
4:50
let me change this to web server
4:52
this is just used in logs that's it
5:06
we have some errors here we will come
5:10
let's start with the handler
5:22
first this is the uri structure this is
5:26
the uri it looks for and this is the
5:30
let's name it led off
5:33
and this will look for led off
5:36
if it detects the uri it will call the
5:47
here we will rename this to led off
5:51
let's delete everything inside and we
5:53
will rewrite this ourself
5:59
here we will first send the log that the
6:04
then we will copy the user c t x into
6:12
here the user c t x is hello world
6:17
then the server will send the response
6:20
if the response will be sent
6:21
successfully it will log it or else it
6:35
in the 404 handler it has been set to
6:38
look for these strings
6:40
we don't need it we can just simply send
6:50
now we need to register the uri
6:53
structure we just created
7:05
we named it led off so we will register
7:17
now in the end we are registering an
7:21
and if the event got triggered the
7:23
connect handler will be called
7:26
the event here it set to dot station ip
7:29
which happens in case of station mode
7:32
but since we are using the access point
7:34
mode we will set it to access point ip
7:46
we don't need the disconnect handler
7:49
so when the ip is assigned to the access
7:52
point the event will be triggered and
7:54
the connect handler will be called
7:57
inside the connect handler we will start
8:01
let's test this much code first
8:14
let's open our terminal also
8:28
note that this particular event hasn't
8:32
so the connect handler hasn't been
8:34
called and the web server hasn't started
8:47
but as soon as one station connects to
8:49
the access point the web server will
8:53
also note the ip allocated to the
9:01
it's because the ip with 4.1 has been
9:04
allocated to the access point itself and
9:07
therefore it's the ip of the server
9:10
we need to access the same uri that we
9:12
have created in the program
9:16
here you can see the hello world is
9:19
being displayed by the server
9:24
also note the logs they are same as we
9:26
put in the led off handler
9:36
the user ctx was hello world and that's
9:39
what was sent by the server
9:41
this is it for the simple web server
9:44
the next video will continue from here
9:47
and we will create some buttons