1
00:00:00,150 --> 00:00:06,010
In this lesson we will be writing some codes to set up the server go to the server API first start.

2
00:00:06,030 --> 00:00:07,870
Import logging.

3
00:00:07,980 --> 00:00:09,850
Set the logger to logging.

4
00:00:09,870 --> 00:00:18,370
Get logger followed by double underscore NAME WE SET THE APP object in the config file.

5
00:00:18,390 --> 00:00:21,020
So we need to import config.

6
00:00:21,030 --> 00:00:24,220
This is a local config file so we need to set a blank.

7
00:00:24,210 --> 00:00:26,640
Row after import logging.

8
00:00:26,970 --> 00:00:30,680
Let's create the app object with config app.

9
00:00:30,690 --> 00:00:32,990
This is the flask app object.

10
00:00:33,420 --> 00:00:37,320
Next we define index and return the text hello world

11
00:00:40,790 --> 00:00:42,980
as we saw in the flask code sample.

12
00:00:43,010 --> 00:00:49,610
We need to set the decorator at Mark app roots followed by a slash.

13
00:00:49,610 --> 00:00:51,980
Now we create a function called Run.

14
00:00:52,130 --> 00:00:54,460
We need to use the app to run this.

15
00:00:54,530 --> 00:01:02,700
So we set app run followed by host as config web address and port we'll be config web port.

16
00:01:02,750 --> 00:01:10,220
There is also an option for threaded which we will set to true usually flask app will launch using a

17
00:01:10,220 --> 00:01:14,540
high performance web server such as a patch or engine x.

18
00:01:14,780 --> 00:01:20,750
Although the standard flash server will be a slightly slower performance server where a multiple thread

19
00:01:20,750 --> 00:01:23,820
requests will not be accepted at the same time.

20
00:01:24,230 --> 00:01:30,140
By setting the threaded option to true the web server will accept multiple thread at the same time.

21
00:01:30,140 --> 00:01:37,160
Now we want to set the run function to be invoked from the main P Y file open the project tab and select

22
00:01:37,190 --> 00:01:43,460
main P Y set to import drone app controllers server.

23
00:01:43,460 --> 00:01:47,670
Once the main B Y is invoked we want the server to be launched.

24
00:01:47,870 --> 00:01:48,750
So let's set.

25
00:01:48,860 --> 00:01:56,540
If double underscore name equals over underscore main then drone app controllers server run.

26
00:01:56,540 --> 00:02:03,820
Function go to the go button on the top and click the triangle and choose edit configurations.

27
00:02:03,890 --> 00:02:06,670
We need to set the path to main P Y.

28
00:02:06,710 --> 00:02:13,960
Click on the folder icon on the right and choose the main P Y file check to see that the script path

29
00:02:13,990 --> 00:02:21,840
is set to the main P Y under the python Tello directory if the path is correct hit.

30
00:02:21,880 --> 00:02:26,430
OK start running this code.

31
00:02:26,650 --> 00:02:28,710
You can see that the H TTP.

32
00:02:28,720 --> 00:02:30,080
Call on slash slash.

33
00:02:30,100 --> 00:02:35,290
Zero point zero point zero point Colin five thousand slash has been launched

34
00:02:37,990 --> 00:02:39,270
once you click on the link.

35
00:02:39,310 --> 00:02:42,750
A new browser will launch and the screen will show the text.

36
00:02:42,760 --> 00:02:48,710
Hello world if you see the correct link with the word hello world on it.

37
00:02:48,820 --> 00:02:57,640
This means you have successfully set the flask we've just finished the config and flask settings before

38
00:02:57,640 --> 00:02:59,210
we go onto the next step.

39
00:02:59,230 --> 00:03:07,240
I want you to see that we set the stream to assist dots as out to show the log in the console to have

40
00:03:07,240 --> 00:03:09,190
the log log on a file.

41
00:03:09,190 --> 00:03:11,210
We need to set the file name.

42
00:03:11,500 --> 00:03:15,480
File Name equals com fake log file.

43
00:03:15,850 --> 00:03:20,410
We haven't imported the config so we import it as well.

44
00:03:20,410 --> 00:03:23,160
Again let's see what happens if we run this code again.

45
00:03:24,050 --> 00:03:29,870
You can see on your left side that a new file called P whitetail log has been created.

46
00:03:30,680 --> 00:03:34,690
If we open this file you will see that info logged on this file.

47
00:03:35,390 --> 00:03:40,790
So if you prefer to have your log on a separate file you can set the file name.

48
00:03:40,850 --> 00:03:47,000
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

49
00:03:47,000 --> 00:03:48,290
log for debugging.

50
00:03:48,320 --> 00:03:52,490
You should set a founding the option settings will be up to you.
