Modern Python Projects Transcripts
Chapter: Let's build a CLI
Lecture: Possible improvements

Login or purchase this course to watch this video and the rest of the course contents.
0:00 This is where we end, adding new features to our tool. But if you find it interesting and you want to actually use it,
0:07 there are many more improvements that you can add. First of all, we can make this code asynchronous.
0:13 Otherwise, if there is a website that takes long to respond, it will block all the other URL's. So, when you want to ping multiple url's,
0:21 using an asynchronous code is a textbook example. You can also send an email, when the website is down.
0:29 Python has a module called SMTP lib, that you can use to send emails. You can provide credentials, for example,
0:36 for your Gmail account and then add a function that will send you an email when one of the website is down.
0:43 You can also add an option to display and notification when the website goes down. Right now, when we run uptimer in a daemon mode,
0:50 we still have to check the output in the terminal from time to time. So, it would be cool to get a pop up notification on your computer.
0:59 This is not an easy task because every operating system uses a different tool to send desktop notifications. So if you're looking for a challenge,
1:08 check how to display notifications on your operating system from Python and try to add it to
1:13 our uptimer application. You can also add the script to a Cron job and have it run every minute or every five minutes.
1:21 Cron is like automatic tasks scheduled on Linux, so if you have never used it before, you can check it out. But when you use it,
1:29 it will run your application in a regular interval so you don't have to actually run it in a terminal all the time.
1:36 You can add a database or a configuration file to store the list of websites that you want to monitor. That way,
1:43 you don't have to always provide full list of url's, that you want to monitor. When you restart your application, you could start the
1:50 URL's in the database and add some functions to add list and delete URL from the database. You can use a fancy database like Postgres SQL or mySQL.
2:02 But Python comes with SQL module built in, so you can just import SQLlite three and create a database in the current folder
2:11 and that that's enough to get you started. And if you want something really advanced, you can add different types of requests,
2:17 not just the head request. All those tools that I showed you at the beginning So the uptime robot and pingdom they let you,
2:25 for example, specify a user name and password, and then they will try to look in at your website.
2:31 That way, you can check not only if the front page of your website is running, but for example, if the users can log in,
2:38 so if the database is working fine, this will require a lot of changes. You need to add additional parameters to accept the user name and password.
2:48 Then need to set up some SSL configuration to send those password securely, and you need to add support for post request to the main function.
2:57 But when you do this, you'll have a really powerful uptime monitoring tool. In the next chapter, we will take the uptimer and publish it on pypi.

Talk Python's Mastodon Michael Kennedy's Mastodon