In this lesson we will be connecting the front end side to the back and side open the server API file.
Let's start our code under the game shake function.
Here we will be creating an API where we can command the back end to start the course set the decorator.
This time the path will be API shakes start next as the methods.
Usually this will be post but we will add get as well so we can debug we define shakes start the course
I.D. will be set to request args get followed by I.D..
So we can get the I.D. if the method is set to post.
We will be using form instead of ARGs.
In this lesson we'll be using get so I'll comment out on this line.
Next we need to get the course set variable course to get courses in it and course i.e. next course
start and return.
Jason ify result to started followed by two hundred okay response.
Once the course starts the phone will be shaped.
Here we need to create an API that will send a request to the back end once the phone has been checked.
Set the decorator.
This time the path will be API shake.
Run methods will again be both get and post.
Let's copy the codes to get the course I.D. from the previous code.
Set the function name to shake.
Run to run this function.
We set to course run the return we'll be set to J sonnet 5 followed by the lapse time of course elapsed
status with the core status and also to check if the drone is running on the course or not.
These information will be returned to the front end and not to forget the 200 OK once you've finished
your codes we'll be running these codes.
We won't be accessing with the phones yet we can use the Mac browser to access the you or else turn
on your drone and let's run this code.
It'll be much easier to understand what is going on.
If we look into the course P Why file click on the U.R.L. in the U.R.L..
I want you to add slash API slash Sheik slash start.
Question mark IDR equal 1.
Here we started the course.
Now let's change that you are able to run and hit the return button.
You can see that the drone takes off once the drone is in the air hit the refresh button so the status
will go up as the status reaches 10.
The drone will rotate clockwise 90 degrees go on refreshing and at status 15 again will rotate.
Then we hit status 20 so the drone rotates again once the status hits 25.
The drone rotates and we'll be facing forward go on refreshing and once the status reaches 30 it will
flip to the front at status 40.
The drone will flip back once we hit status 50.
The drone will land and the status will be cleared back to zero.
I hope your drone flight was a success and see you in our next lesson.