In this lesson we will be writing some codes to set up the server go to the server API first start.
Import logging.
Set the logger to logging.
Get logger followed by double underscore NAME WE SET THE APP object in the config file.
So we need to import config.
This is a local config file so we need to set a blank.
Row after import logging.
Let's create the app object with config app.
This is the flask app object.
Next we define index and return the text hello world
as we saw in the flask code sample.
We need to set the decorator at Mark app roots followed by a slash.
Now we create a function called Run.
We need to use the app to run this.
So we set app run followed by host as config web address and port we'll be config web port.
There is also an option for threaded which we will set to true usually flask app will launch using a
high performance web server such as a patch or engine x.
Although the standard flash server will be a slightly slower performance server where a multiple thread
requests will not be accepted at the same time.
By setting the threaded option to true the web server will accept multiple thread at the same time.
Now we want to set the run function to be invoked from the main P Y file open the project tab and select
main P Y set to import drone app controllers server.
Once the main B Y is invoked we want the server to be launched.
So let's set.
If double underscore name equals over underscore main then drone app controllers server run.
Function go to the go button on the top and click the triangle and choose edit configurations.
We need to set the path to main P Y.
Click on the folder icon on the right and choose the main P Y file check to see that the script path
is set to the main P Y under the python Tello directory if the path is correct hit.
OK start running this code.
You can see that the H TTP.
Call on slash slash.
Zero point zero point zero point Colin five thousand slash has been launched
once you click on the link.
A new browser will launch and the screen will show the text.
Hello world if you see the correct link with the word hello world on it.
This means you have successfully set the flask we've just finished the config and flask settings before
we go onto the next step.
I want you to see that we set the stream to assist dots as out to show the log in the console to have
the log log on a file.
We need to set the file name.
File Name equals com fake log file.
We haven't imported the config so we import it as well.
Again let's see what happens if we run this code again.
You can see on your left side that a new file called P whitetail log has been created.
If we open this file you will see that info logged on this file.
So if you prefer to have your log on a separate file you can set the file name.
For now we won't be needing a log file so we can have the log in the console if you wish to use the
log for debugging.
You should set a founding the option settings will be up to you.