In our previous lesson we installed the main packages open the main P Y in this lesson we will be using
the config settings to decide what data goes to which file for example where to create the log files.
Let's start by creating a config P Y.
Right click on P Y Tello and choose new.
Then click on new python file and set the file name to config and hit.
OK.
Lets close the project tab.
Set to import os.
We will also be using flask so set from flask import flask.
Now we set the web address to default.
Zero point zero point zero point zero which is your own host No the web port will be set to 5000 which
is the flask standard project route will be set to 0 as path D by our name in the parenthesis we set
o as path a B as path with the double underscore file which is the name of this config file.
With this we can check which directory we are at.
Let's copy this code and go to terminal type Python so we can start the shell set.
Import os now we paste the code we copied since we are using the shell.
We cannot use double underscore file name.
So let's say delete this file name and set the actual file name dot slash com fixed up p y as we run
this code you will see the directory name P wide Tello which is the directory where the config P Y file
is.
This path is what is in the project route.
Now let's go back to the script.
We also want to set the template directory type o s path.
Join project route drone app slash templates.
Now is that the path to the static folder.
We'll do the same as what we did before.
Always path.
Join project route drone app slash.
Static let's go back to the project tab and check we can find templates under the drone app.
Also we can find static under the drone app the debug mode can be also set here.
I'll set it to false for the moment.
If you want to receive more information while you develop the app you can set this to true.
Let's set the log file to Pete tell dot log which will be set to the top of the project.
Now I want to set the flask config.
This is the flask Web site.
Go to flask dot P O C O dot org.
On this site you will find the flask code samples the code here says we import flask set flask double
underscore name double underscore to create an app object.
Then we use this app object to create decorator at AP dot root slash.
This means that access will go to h TTP call on slash slash.
Zero point zero point zero point Colin five thousand slash.
You can imagine this as the top page of the site.
Once we access the top page hello world will be returned by using flask.
We are able to go to certain sites or also use apps to make all sorts of settings.
Here's a very short program but we will get into more details on the way.
Just wanted to introduce you the idea for now.
Now let's go back to the config P Y to set the app object so we can access it anytime.
As we just saw on the site we set the app object followed by flask double underscore name.
There is an option called template folder where we can set the HDMI all template folder.
Here we set it to templates.
Also we can set the static folder as well.
Here we completed setting the app object if you are planning on using the debug mode set.
If debug app debug equals to debug as we set the debug to false this f statement will not run but if
you change the debug to true the process will go through this.
If statement here I set the log file to p tell.
But you can also change the file name to p y Tello or P Y.
Tell whatever name is fine.
Finally we've finished setting the config file.
Now we need to launch a server from the main P why the code to launch the server will be set in controllers
right click on drone app and choose new choose python file and name the file.
Double underscore in it and hate OK on the left here you'll see that in it file that we just created.
Again right click on controllers and choose new.
Now select python file and again name the file double underscored in it and hate.
OK let's close all these tabs now right click on controllers and choose new choose python file and name
the file server and hit OK here we've created the server.
P Y.
I'll see you in our next lesson where we start on the server side.