📺 Develpreneur YouTube Episode

Video + transcript

Django-Python Application Tutorial Part 2

2021-06-03 •Youtube

Detailed Notes

It is time for us to take our Python and Django skills to building a full application.  This is part two in a two-part series of tutorials where we build an application from scratch.  This series will walk through all the steps required to build your own solution.

A Python/Django Site Monitor

The application we build is a web solution for monitoring web sites and API end points.  We can configure the application to simply do a heartbeat check or validate the content returned.  This second part of the series focuses on the back-end python code.  This is the "guts" of doing the checks and scheduling them.  The bulk of our tutorial covers the Django steps, but there is plenty of Python to learn as well.

Transcript Text
[Music]
[Music]
okay
so we're gonna go into part two
of our python django example um a couple
weeks ago now a couple sessions back we
got through part one
it ended up being a little more
complicated than
uh we could handle in one session so i
think we'll be able to do it
in this one uh there may be a couple
there are some additional things that
we're not going to go as deep into that
we'll probably do better just to be sort
of standalone
kinds of other areas that we may want to
go into but
the goal was to basically take things
that we'd talked about
in about django and python in a couple
of prior
sessions and roll them into a nice
little application that we could build
and work on
and so that's uh that's what we're doing
here
now since it's been a while we're going
to start out by we'll take a look at our
app so far where
we're at sort of where we left off last
time around
and then we're going to talk about
django one of the key things here
is taking the django piece that we saw
for front end
for being able to use it really is a
really nice
object relational mapping tool and and
using it to do
data management things like that and
using it in a
headless environment so you know
flipping to the other side of doing a
non
something without a user interface in
front of it and some of the
little bits of things that you need to
do there
then we're going to focus on the back
end process of our application
and working through the various types of
responses that we had there
and so let's talk about what we had last
time around
the key to this application is this
going to be it's a way to
monitor sites and api endpoints we just
want something that's just a nice
application that allows us to take a
look at you know sort of just have
something that's
occasionally checking you know like
heartbeats or values or something like
that to make sure that our
our api is up if it's an api our website
is up if it's up
our page is returning what it's supposed
to return if we've got a web page
and we looked at this with two different
focuses one would be really just more of
a heartbeat or a ping
and then uh the other is something where
would be more like an api where we're
actually we want to
check a value you know return value we
want to do something more than just say
hey do we get a you know a response from
a web a url
essentially and um
look at we had a front end that was our
essentially our administration
and reporting side of it so we could
take a look at what's out there
as far as um and we could add a site
remove a site edit the settings for a
site
and then there's a back end that is that
really is that heartbeat thing that
periodically
you know wait essentially you know wakes
up
runs through the checks that it needs to
check and then updates everything so we
can see how our sites are going
uh let's see so let me i'll flip to this
first if i've got it nope it wasn't on
this one it is on this guy so this is
roughly what we built
um now we're gonna this is a sort of the
new version of it so we're gonna talk
about some of the changes have been made
uh but essentially what we've got is
we've got these various sites that we've
added
and we can see in some cases
let me just do an edit on this in some
cases we've got
something where we're looking for a
value and we've got a url that's
actually sending some parameters
and then we've got others where it's
really just a
ping like the developer nurse site we
just go out there and we just say hey
you know i'm gonna see is it alive and
if it is then it's gonna give us a
you know a success or not
and normally we just see either you know
there's a failure or the site is alive
so let's flip back here so that's our
front end
now the back end obviously not as
visually
interesting or anything like that but
what it's going to do is we've got for
all these sites
for each of these sites or addresses
that we've built
it's going to go through there it's
going to see basically it's going to say
hey do i need to run this do i need to
do a check against it
and then i'm either going to do a ping
or make a call to that site based on
the type of uh here basically
the type of call that i'm doing
and then i'm going to update to make
sure that i've got that you know it's
got the latest result
and then we're actually going to talk a
little bit about uh cron versus
scheduler because we've got a couple of
ways that we can do this
and python itself uh is even you know
more
rudimentary than it's not even a django
thing it's a python thing is they've got
a built-in schedule tool that may work
depending on how we want to do it may be
the better approach for us
so in setting up that script we talked a
little we just
very briefly touched on it last time
around
so this time i want to spend a little
more time we're going to talk about the
basics of the script
setting up the getting the django
settings into the script so that we can
utilize
all of that uh the models and
basically the database connection pieces
that django gives us for free
since we've already got those in the
django application we want to use those
in our script
and then we'll walk through you know
some basic queries and
a simple example of running the script
what it looks like and
what kinds of things are going to be
going on with it
so let's jump over to some code
and let's start with let me blow this up
a little bit bigger
so actually i'll start with the just as
a as a refresher so the models was very
simple the database model is very simple
we have sites
so each one of those things those boxes
we saw on the interface is a site
and essentially it's just got what we
saw you've got a name a description
the url that you're trying to hit and
then some information to keep track of
you know what was the last result
uh when did it last uh when was it last
updated
and then there's some lookup tables
related to those
so it's very simple data model
and when we jump over to this pop-up
thing that's driving me nuts let's see
put that there
um and so we're going to jump into our
our back-end script now the first thing
that we've got is the bringing in the
django
pieces and that's actually fairly
straightforward it's not
terribly complicated uh if you remember
we
set up here we have the set
django's got a default settings file
that it gives us and then we did make
some
you know some changes to it so that for
example
uh here we could use a mysql database as
opposed to a sql white that they
give us by default and then we connected
it to our
our database for this application
and we want to use those same settings
and so in a script
it's actually pretty straightforward
there's a a class
that's called settings and so we can put
in that we can pull
import from django.conf
and then it's it this import os os gives
us operating system
kinds of things that we can do some
access to that
and all we need to do is we're going to
come in and we're going to grab we're
going to set
actually set the environment for the
django settings
we're going to set it equal to our uh
our project and then our settings file
and this project was called monitor
and then and actually we can do this in
any order we want to essentially just
import but we import the django stuff
all of its classes and functions we call
django setup
and boom we're off and running so if you
wanted to utilize
the stuff that you set up for django
in a script then those five lines will
get you there
the only thing you'll have to do is just
tweak it based on your application name
and the settings file and then just make
sure that it's you know you
depend on where you run the script you
may have to
make sure that's properly in the path
but that's all you need to do it's a
couple lines of code
and boom you get the whole
infrastructure of django
you know available to you which is key
because that allows us to utilize all of
those models
that we use you know that we built out
now we've got um we've got a couple
different
imports here that i'm going to i'll sort
of touch on as we go
uh one of them is datetime and pytz
these are these are really the
these are key python date related
stuff for lack of a better term not to
get too technical
and what you do with those is you get
the ability to work with dates
date times uh do calculations and and
differences diffs between those uh
actually or
if you want to call it more specifically
as they do at deltas
and uh you see right here is that we you
can that pytz
allows you to do it's basically python
time zone it allows you to set a time
zone so you have a context
for your uh your times your date times
and your times
and that's pretty key so that you don't
end up just everything going to
um greenwich mean time so you can do it
to you know match whatever your your
local
system time is now the first thing we're
going to do
let me make sure i want to do that yeah
so we've got our we've got our basics
set up
we're connecting to django we've got
some basic time stuff here
so let's look at our ping uh
luckily that is insanely easy to do
because what we're going to do is we're
just going to use in our case we're just
going to use the operating system
ping and we get that
through platform when we import platform
it's going to get us a um it tells us
what operating system we're working on
and then sub process allows us to
actually call something
basically it's just you know hey make a
shell command
and so all we need to do in this case
for the ping is actually pretty easy
we're going to send it in
an address and then we're going to do
either a dash c or dash
in depending on whether it is a windows
operating system
or not and so then all we do is we just
build out our command
which the command is just you give it
the command this is the operating system
or the shell command so this is you know
so we do ping
we're going to send a parameter we send
it a value and then we're going to send
it
the hostname in this case which looks
like
if you do this it would be ping dash
in 1 and then i could do like https on
developer newer
dot com and i probably missed something
there
what did i mistype that oh i think it's
because it's a dash one
i bet that's it maybe not
so i maybe whoops nope so i missed one
there but basically what that does is it
says
and because i think i got that well that
should be
there it is i must have missed something
oh i'm sorry not dash c
i'm sorry n is for windows c is for not
so
whoops and basically all that does is it
says ping it one time
so go out check that one time and see if
you can find it
and apparently this one it doesn't like
it right now
and so all you do there is then you're
just going to return whether that call
was successful or not
and so that's our ping so when we're
doing over here
we're trying to see like for this site
is it alive
then all we do and this is uh we call it
heartbeat so we've got two different
types
we have ping as the heartbeat and then
data return is gonna
we're gonna do something more
complicated than a ping
and then all we need to do is set the
time amount how often do we check
and then we're off and running and so
here
we've got our ping and now let's look
down here search up to the bottom here
jump to the end in a little bit uh what
we do
is and this is a full script so there's
a couple things we're going to come back
to
but right now for the pings we're going
to call those heartbeats so we're going
to call this check heartbeats
and just note i guess that this is all
you know an inline script so this is a
function we've got the ping function
we create check heartbeats function the
check request function
and then we're going to come down to the
main part and we're going to check the
the heartbeats
check the requests and then there's some
extra stuff down here that we're going
to do that we will talk about later so
let's talk about the heartbeats
and since we're using the django
models this is really easy to do all
we're going to do
is we're going to use the model so we're
going to go to our sites
which is where did i put models
ah there we go so i'm gonna go into the
sites
and i'm gonna check everywhere that ping
is equal to one because that means that
i wanna try a ping
and so i'm going to grab all of them and
i'm going to filter it by ping id
equals to 1. i'm going to go ahead and
this is where i'm using that
utc time i just want to get my you know
what time is it now
and i'm using this date time it's pretty
straightforward
it's just a today which is probably
pretty
familiar if you're dealing with date
time stuff anywhere
almost every library framework has
either
now or today or something like that
and so that's we're going to do is we're
going to take the today we localize it
to
because i'm on utc i'm going to localize
it to that and that's equal to now
and so i'm just going to walk through so
i list i've got all my sites that were
returned
from this query and i'm going to walk
through each one and i'm just going to
say for each of the sites
then i'm going to see if the last time i
checked it
is either empty or
it's equal to or i'm sorry actually the
last time i checked it plus whatever the
frequency is
and that was and the frequency is how
often do i want to
uh what is the period of time between
checks so if it's every five minutes
it would say when was the last check
plus five minutes
is that less than now so is that already
passed
if it's greater than that amount now
then that's in the future
so we basically say hey if we've never
checked before then we're going to go
ahead and check
and if we have we just want to see where
that time frame sits
and if we do need to check it
so if we don't we'll take that that's a
short path we're just going to say we
skipped it so we'll see that
come out that we just skipped that site
otherwise
uh we're going to grab the host out of
the
um out of the data for that record
and then we're going to ping it and um
all we do we actually don't need for the
ping which is where i had the problem
before is i don't actually do the https
colon backside backslash i'm going to do
it without that
and so then i'm going to get my ping and
so that results
i'm going to grab the result from the
ping oh i'm sorry
first i'm going to go to my various
results and basically i either have
it's either fail or the site is live
and so i'm going to check i'm going to
go grab my fail
object because i'm actually getting
result that's
the result that i get back from ping is
actually going to be potentially an
object
um and so if the oh i'm sorry
it's not it's just a zero one but what
i'm going to do is i'm going to say if
it
is a one so if it's true basically
then i'm going to set it equal to the
uh the live object and this again
remember that we're dealing with
uh we're dealing with the model the
attributes are actually
objects and not always uh not
necessarily an id when you're working
within the django world
so i have a last result
since it is here since it's a foreign
key on lookup result
although i can go in and just do it by
id what i really want to do
is do it by class so i'm just going to
grab a lookup result
value and shove it into last result
and that's what i do here is i go in and
i do look up results
and i'm going to do a get where the code
is equal to
live and let me um
let me switch gears just a second here
and open up the admin side
and so we see here is that i have um
for my results there's four different
things that are out there that i've got
in that lookup table
and i don't have an actual really that
i'd care about i don't have an actual
numeric
id but i do have if you guys remember we
have these
unique codes so that's what i'm looking
for i'm either going to grab the live
code
or the fail code and if the result i get
back from the ping
is true then it's live otherwise
it's going to be fail and then all i
need to do
is i'm going to set the last result
equal to whatever this result is
i'm going to say that the last time i
checked it was now because i just
checked it
and i saved that record and all of this
i'm i'm utilizing
through these three things i'm utilizing
django's model stuff
to allow me to quickly you know with a
few lines of code be able to do all of
that
so now if we look let me open this up
just a little bit
so if i were to run this monitor this
thing called monitor engine all i need
to do is it's just a straight python
script
so i'm just going to do python and then
i'm going to send it the script that i'm
running
so when i run it what we'll see
is right now it's kicking out i'm going
to see the results
i'm sorry the the uh since i'm sending
this command
and let me see where did i run it here
somewhere up here here we go so then
what it is i'm going to see each of
these pings so i'm pinging and i've got
multiple sites
you can see here that i've got multiple
sites that i'm
i'm doing checks against now
i think this one and this one and this
one i think i've got three
three are just pings yeah there's a
heart three are heartbeats
and then two are gonna be uh looking at
data returned
and so if i look at those three
developing or rb consulting in my time
matters
oops i'm going to see each of those when
it's going to go out and try to hit
those
and so it's actually giving me here
so let's see so this one is
developmenture.com
it does rb sns and it does my time
and then it's going to come in and it's
doing the others we're going to look at
later
now if i run it again up and actually
since right now i've got it scheduled to
keep running let me change that real
quick
pull this out
okay and i'll come back to that in a
minute so this time
because none of these have uh the time
hasn't passed for each of these
then it's just going to skip each of
those sites because i've already
hit each of those up so in each of these
cases
we can see where uh the frequency was
you know
it hasn't been long enough for me to
want to do a heartbeat again
so this is where our general engine for
the application is going to work is
we're going to kick this thing off and
let it just run regularly
like for example every minute and if it
runs every minute
then when it runs it's either going to
skip stuff or
it's going to update some of these
things and so we can see here like
developing or it just updated again
and then on our site on our front end
we're going to see where each of these
uh where we get
our last update and so we can see for
like
example this one this rv consulting is
more frequent apparently because it
updated
on 351 where the other ones did not
and so that's our i think that's what i
cover for this one
so that'll go so for now that's our
initial piece here i'm going to come
back to this but i wanted to
get us through the most general version
of the application
particularly the back end
so we've talked about whoops uh yeah
there we go so we've talked about ping
and so that one was pretty
straightforward we're just gonna we're
just gonna hijack the operating system
ping
so you know it's already there why not
now uh jen or python actually gives us
a nice way to do our gets and posts and
things like that so we're going to work
on a get
we're not going to get into posts and
puts we probably could if we wanted to
but it seems like that would be
a little bit complicated you probably
want something that's you're really not
going to do that as a heartbeat for a
site if you're doing puts in posts
then you're probably updating data and
although you can do that as a test i
would think you probably would not want
to so we're going to keep it simple for
this
this type of application and so we're
going to
now switch gears a little bit from the
ping to get and then with git we're
going to get a response
and we're going to look at a class in
python that allows us to to work with
that fairly
simply and straightforward
so now so we did our heartbeats let me
shrink this where is that at let's
shrink that down a little bit
so that was heartbeats that's going to
go through everything that
is looking at the heartbeat side but now
the other option we have are requests
and this is where we're going to
actually be able to look at a value so
for example
we're going to have um in this case
we're just hitting our our server which
is this thing
and we're going to hit it with an
address that we want to actually see
what is the result that's coming back
and we're going to check this every five
minutes now as an example i want to go
look at that let's see
create a window if i go hit that this is
what i'm going to see
normally got something very simple and i
built this
this and the other one i added two
little
test urls to my site so
hb is just this heartbeat and this is
something you may want to do
for your site i've seen this a lot of
times where instead of just
essentially doing a ping to make sure
something's available
and you would you would use this a lot
where you've got
for example like maybe an api that you
want to see if the back end is
up and you've got a some mobile apps
that are hitting it then maybe the first
thing they want to do is do some sort of
a status check against the api
in general and so maybe you would have
like a heartbeat call or something like
that
that sends you know something back it
may be just something like hey i'm alive
uh sometimes you'll see and you'll get
this actually go out to some
major apis and they actually have status
pages
and so they may break this down so it
may be you know the site is responding
and they may have
uh you know front end is up back end is
up um migration
tools are up you know something back up
is down
you know something like that is that you
may have actually something pretty
complicated that you'd want to check
against
and so we just to sort of give a an
example of that
as opposed to having to build out you
know walk through a little api example
i just added these into this site so
it's pretty easy for us to
to play around with them for setting up
stuff locally
so i did hb and then i did this other
one that's just m which takes
two values and multiplies them and so
that one
uh here whoop let me go back here
so what i did to test it
is i'm just going to give it 3 times 6
and then the value should be 18 and this
would be much more like a
an api kind of call where i would do
something like this
and then i should get a value back
so i've added those two in for us to
play around with
this second piece and so now let's take
a look at that
uh and just actually i guess just for
clarity we'll just walk through those
real quick
uh let's see so heartbeat
uh i think we've talked about this
before but in both these cases all i'm
doing is i'm just i'm not going to our
normal
normally what we're going to do is we're
going to build some values out and we go
to our html
essentially our template pages so if i
look at
this page in the django world
it's siteless so if you remember i've
got this thing where i've got these
content blocks and then i've got some
html that i'm
basically building based on that
and in this case go back to
[Music]
go back to my views here we go
in this case instead of rendering
as we do with html i'm just going to
build out a raw
http response and we see that when i did
the heartbeat is all i did is i just
sent it a string
and it kicked it back and uh in the
multiplier
i've got my two values and i just
multiply those out
now i can do something you know
complicated i can do
uh hello world
and if i change that and go back to
heartbeat
then now i'm just sending it and it's
just like you can see
it's just raw html
of course now if i do that and i run my
monitor
then i'm going to see
here that heartbeat failed
and this is something actually that we
i'm going to talk about in a second but
we did change this up a little bit
we clean this up because last time these
were just straight
uh backgrounds so actually now i've got
something that's a little more
colorful we'll take a look at that in a
second or a few minutes as it were
and let me kill that so that doesn't
just continue to run
and now we so we can build our response
and we can do whatever we want to
uh as part of that response
it's really nice for again we don't need
to have a full-blown
an actual api although we have looked at
that in the past
we can do something like this and just
you know have some values some urls that
we build rather quickly
you know it's just hey this is what i
want the arl to look like and then we
can
you know force a response out that
doesn't have to be we don't even have to
build our html page
we can just do something just a straight
response
so let's go back to our
our primary engine here
now before uh if ping is equal to one
uh and this is the ping id which i could
have grabbed
the uh ping value but i just kept it
this is an example where we can send a
class
like we did here or i can just go in and
say
just directly you know i'm going to cut
to the chase and i'm going to send an id
and i know that my two ids and i'll look
at those real quick so
the ping types are either data returned
or heartbeat
heartbeat has an id of one you can
barely see it there
which technically i would never need to
see i probably should do it
by heartbeat code here like i did with
my lookup result but i just wanted to
show that's
it's cleaner to use it by code and more
uh
resilient because if for some reason the
actual id of that record changes
then that would break it but i wanted to
show that you can
actually just directly instead of doing
it by ping
i can use an underscore id and then just
send an id value across
um let's see and so i oh here we go
so check request before i did it where
the id is equal to one this time
so do the same thing i'm going to grab
my sites where
now instead of the heartbeat i'm doing
the value
i still use that now that i used it
before
so i get the current time stamp what is
it today right now
and then i'm going to watch through walk
through each site and essentially the
same thing i'm going to say hey if i
haven't checked it or
um well that's neat i used
i didn't need i don't know why i doubled
that up but there you go
uh or if the last check was
since uh was more recently than i want
to do my
uh period my period of checks then i'll
skip it
um i'm sorry or if it
if it is within the frequency so if it's
longer than the last frequency or
it's empty i'm going to do something
otherwise i'm just going to say skipped
it
which we saw before now before we had
the ping
this one's actually not much more
complicated
now here i've got some prints to show
the
result text and status code
which i think we can see here so
for the ones that we've seen so like
here if you can see the latest one i did
is it actually kicked out this was the
text of the
of the result and this is the http
response
and so i can check for thing because it
could be like here it's a 200 but it
could be a 400
a 401 a 500 you know all those other
typical responses now i can
if i want i can say that for
these these uh value checks that i want
to make sure that i do have a 200 plus
a value but i'm keeping it pretty simple
in this case
and i'm just going to say that if it's
not a 200
because we're just doing it basically
it's either yes we're getting something
or no we didn't
um so one of the things we're going to
do is first we're going to see
well actually i sort of messed with this
one a little bit but this one
first we're going to see is the result
here so i'm going to get result is the
actual result by default i'm going to
assume it's a fail
otherwise if the desired result is equal
to 3
and this is oops this is where i've got
two different versions of this value
check
so it's either the simple response or
the value response
the simple response says is it a 200.
the value response says i'm going to
give you a value
and i want to check against that
and we see that uh let me go back to my
admin
and so here for heartbeat
this is the value i'm checking against
if i wanted it to just be
a simple response then even though i
have a value it's not going to care what
that value is
and so it allows us you know we've got a
heartbeat which is a ping
we've got a get which is the uh simple
response and then we've got the value
response that says not only am i going
to do a
http get
a web get i'm also going to check a
value that's returned
hey rob good question yeah um go back to
your other screen for a moment
uh the listing screen yep this one no
right there okay
so i'm assuming there's a way in
uh django to do this but uh is there a
way that it
based on your drop down will hide or
show that
desired value uh
what do you mean it's so that
oh oh so like if i do this it would
either hide or show this
yes and it's not actually uh that's
actually at that point it's not a django
thing it's really it would be a standard
javascript thing
so what i would do um and this it
that does get a little bit tricky
because i think this is uh let me go
back to that
that's a good side question uh if i go
to the list i think i'm using a
form um
no i'm not uh let's see am i using a
form no i'm not so what i would okay
what you would do is you would okay so i
get now so you
update it here based on
so it this would check ah yeah there it
is okay so you got if code in there all
right
yeah i was trying to follow this earlier
uh
and you kind of went a little faster but
i i see it now okay
cool yeah so so what i could do yeah is
and i don't think i had any of that
built in but yes so i could do that and
just say based on that value that these
things are going to be
visible or not um and
yeah django doesn't give us anything
special on that but it's
it's actually it's now we're just down
to you know standard
uh web stuff at that point
so good question right yeah yes so it
kind of looks like it's a
so the way django does the web displays
it's kind of like a jsp
or um you know the jstl tag precisely
precisely is it's it's really there it
add
it gives you your um more like a
template
essentially and it gives you some you
know like jsp or
asp or any of those it gives you a way
to do some tags
but then the rest of it is your you know
you're building it into your
your page itself and you can build and
then you can include
um like here you know you can build
um you can you include javascript as
needed
and it's just gonna yeah it's gonna spit
out your html on the back end
okay cool thanks that answer from the
question good question
all right so
uh so back to that so we've got our two
different things we're either going to
say
if my result and this is again that's a
good example here
of where while i can use my ids it is so
much easier to read
if i'm building it based on like a
readable code value
so desired result equals the three
actually
if we look here is going to be i think
that's the value response
yeah this value response so it would be
easier if i was actually doing code i
would at least see value
or i could do it by the name so that's
something much more
developer friendly instead of what is
almost effectively a magic number
because it's like i don't know what a
id3 is unless i go back and look at the
database
so while it may be a shortcut in a sense
for me to do this as an id it really
is not as good maintainability wise
and it is a little i guess it is a
little bit faster because i'm not
grabbing that object
so there is that there is a cost there
but you could do some of this stuff
where
i don't have to you know i can actually
get a couple of these objects and cache
them off at the start
but i digress so here we are either
going to check the value
in which case we've got the two things
we can look at
is we either have results status code
which gives us the status code which is
you know 200 400 401 500 501 or whatever
we check against our status code and we
can say if we're checking that
we just say if it's a 200 then we're
live that's what we're using for
our evaluation otherwise we don't care
what the status code we actually care
what the text is that's sent
and then we want to make sure that um
oh and we want to make sure that that
text is equal to
the text that we say it should be in
which case
let's go back over here this is the text
that we say it should be that is our
desired value and then we go back the
same thing we did with the paint
is again it's like okay whatever the
last
result is is going to be either live or
failed that based on what we got
we're going to set our last check time
to now and then we're going to save it
and then we're off and running so now
and this goes back to what we
had before let me get rid of this guy
real quick
and so now what we're going to be able
to see
let me get that is that we're going to
go through and we're going to check
for where did i run that here so i ran
it
and i'm going to do it's going to do a
ping it's going to do another ping
it's going to do another ping and then
it's going to come through it's going to
walk through and do the heartbeats but
since i've got
no printouts based on that right now
it's only going to tell me if it skips
it
so here if i run it again
then we're going to see where i have my
three pings
and then i have my two others and it's
going to run those but it skipped those
because it
caught them last time
so let's take another step on our uh
interface and talk about that a little
bit and then i'm going to talk about
this the python scheduler
to just uh essentially to clean this up
because right now
the way we've got it you can see is i
have to manually run
this engine each time or create a cron
job that mainly runs it
you know each time and
the interface that i'm showing you right
now is not quite
uh was not what we had so i want to talk
a little bit about how i've
uh updated this let's make sure yes
everybody's
running right now and so i'm going to do
a page refresh
on this page so that i don't have to do
a you know force a refresh every time
to see how my sights are doing i'm going
to change some background colors and
look a little bit about that in the um
and how we can do that in css it's a
little bit of a slide trip but
you know just to show a nice easy way to
do this from css
and we're going to talk about scheduler
uh the nice thing about scheduling
we're going to see it's really easy
it's very easy to set up it's really
easy to create a job schedule the job
and then run it and sleep as needed it's
it's like cron but it's probably even
easier to understand than kron
so it makes it a really nice tool which
is why i want to make sure i cover that
within this application and it does sort
of round out everything so when we're
done
today we'll have an application that we
could you know spin up and run and
set up some sites that we want to work
with and we're we've got a little
monitor app going
so one of the first thing and this goes
back a little bit to the question we
just had
is one of the things i want to do whoops
with
my site is make it so that this thing
doesn't force me to do a refresh is i
want to just do an auto refresh and this
is not a new
trick but one that i want to make sure
that i mentioned
everybody so this is my site list
page this is site list
sites goes to sitelist.html
and if i want to do a refresh it is
literally
that simple is that you can tell your
page to do a refresh
you tell it how many seconds uh
how frequently you want to do it and
then you're off and running
so if i want to do it every second then
i can i'm gonna have to refresh it once
so i get that new value
and now you're actually gonna see maybe
you can see here it's actually
refreshing
every second so if i go in and run my
well actually and i can see here's the
back end where i can see it's just
making this call
it keeps making this call and
if i turn on the update
then what i'm gonna see is now there's
probably a couple yeah so like here
it's already changed its time and if i
wait for a minute or two
it's gonna you know it's gonna pick that
back up so let me turn that off so it's
not doing
it every 15 sec or every second because
honestly
um and actually i can do it every 30
because the frequency the most
frequent check we have in our
application is one minute
so i'm going to do it every 30 seconds
i'm going to do an update i could do it
every minute but
every 60 seconds but i may miss one so i
figure
i'll just do it every 30 seconds for now
and it's a local app so it doesn't
matter too much
so in doing that and now uh it
you know since it was updating every
second it hit an update
now it's going to update every 30
seconds
and i'm going to see at some point i'm
going to see these guys
update so that's a refresh on the page
another thing i want to do
is be able to change these so i can see
if something is up or down so let me
actually um
[Music]
let me break a couple of these so i'm
going to say 3 times 6 is 19
and i'm going to say hb i'm going to
give it something else
to check for so those two are going to
start to fail on me
and what i want to do is i can see let
me go back here as right now i see green
but what i want to do
is be able to see you know have
something that's red if something's down
and i could change these colors to a lot
of different
things which basically is either going
to be here it's either the normal one
for
that i've got for my style sheet or my
class it's either
site or site down that's just the two
things either it's up
or it's down now all of these right now
are up at some point it's gonna check
these two guys and they're gonna go down
and
the easiest way to do that of course is
css
which where did i put my css here we go
and actually open site and site it's
actually site up inside down so let's
just do
that
let's see if i go back here oh i think i
had it oh i'm sorry
is i have that it's either side up or
site down and then i think if i create a
new one it's going to actually pick up
um the site itself so if i create a new
one so here
i can see now these two are down because
i broke those values
if i add a site i'm just going to add a
site real quick
that is heartbeat
if i just just do that
oh and i want to do this
minutes
uh simple response there we go
so here it hasn't checked it so i can
see this guy
actually is gonna be uh he's got no
color
so this means i've never checked it this
means it's alive this means it's failed
and so i've got three different statuses
basically for
a site right now that's uh based on
color
and so that is either site upside down
or just the default site
and we had already the default site
that we had that thing built up and so
all i do
with site up is it's going to be i can
essentially just copy and paste it and
i'm just changing
some colors so i can see here uh let's
see that the
background color i changed that over
and if you see oh this one's not down
but uh before
the text was it was a light i had a gray
with a black text
um it's the the forward the primary
color
well when i flip it i want to change the
text to white so it shows up in that
that green or that red and so really all
i have to do is change background color
here
and let's see whoops and so that's for
site up
site down i'm going to make it red and
boom i'm
you know i'm off and running as any one
of these i can pick that up
and so now we've got a little bit more
um
visual you know interface you get a
little better user experience because
now i'm seeing
those colors in there and like i said
again this is where
if you do stuff following your standards
you know throw some uh
use your css classes like we did you
know from the start
we had uh wait on the site list from the
start we had the site
class so that we were able to do some
styling on these
and so once we've got that then you know
we're essentially we're off and running
now i do
want to say that i think i had site
and i think i had another one let's see
if i look at site
box i got a site hover yeah so i had hi
site hover and uh you may have seen that
that actually does
a little bit of shading and what i can
do is i can actually do that
take that same thing actually i'm going
to move this here
and if i want to get my site hovers for
those then i can do site up and site
down
i'm going to do the same thing and
i did like a site yep and that's just a
[Music]
so i'm strange up here and i'm going to
do the same thing for site up
and oops and sight down
and right now i can see that's nothing's
nothing happens on my hover
oh in this case because it's a css it's
a static change and i need to restart my
server so it's going to pick that back
up
and now i should see on a hover but you
can't really see it
i make sure i got that right set up
hover
hover side down hover side down hover
and i think i did not oop let's make
sure i've got that right i may not be
refreshing it right oh because it's not
gonna
i needed my mistake i need to jump to a
new
window because it's already cached that
so let me instead
move to a private window so it doesn't
hold it and this should
pick that up do my login
gotta enter my password right
and so now you probably can i don't know
how well you can see it
but now it's gonna pick up
my hovers here so all that real quickly
through
css which again goes back to just like
one of those nice little things that
says hey
you know make sure where you can use css
classes and it makes your
one it makes your interfaces a little
cleaner uh you don't have these like
special you know fonts and other things
that you need to do just drive it
through classes
and then when you want to change the
look and feel quickly then you can do it
here so if i wanted to do
like real quick and say that i don't
like
red i'm gonna make it blue
if it's down
and then i come in let's see i'm not
sure if it'll do it yeah and then i
force a refresh and then boom i can
change that
you know in a matter of seconds
quite literally and when you're dealing
with changing requirements and things
like that
then i would say definitely do that so
that you can handle
uh it's amazing how helpful that is with
a customer that's
constantly changing their minds and you
can actually can show them that almo you
know live you can actually walk through
and do a
a joint session with them and say hey
this is what it's going to look like
and so that brings us to the last piece
i want to talk about is the scheduler
itself
and so um one thing we did not do
in the prior that we would have to do is
pip3
pip is the if you remember it's the
package manager for python
and so what we need to do is we're going
to have to add schedule so if we do
pip 3 install schedule pip 3 being
python 3's version of it
in this case it's going to say that it's
already satisfied if you run it it'll
install it
if you don't it'll say that it's not
going to be able to find the schedule
piece
and that allows us to do import schedule
so i'm going to move these back up to
the top of the
page here to sort of get all of my
imports together
oh let's see and so i didn't have time
twice oh i did have time twice
it's already had time here and actually
dates not being used so i'm gonna get
rid of that so i can clear that up
so i have to do is import schedule and
jump to the bottom here
and schedule works off of jobs and so
i'm going to define and i'm just going
to call it job
and now instead of here you can see
where i had my heartbeats and my check
requests that was my this was what i had
as my main
so what i'm now going to do instead is
i'm going to say that my job
is checking those two and it's going to
print out
job complete just so that every time i
run the job i'm going to see that hey
you know i ran the the job
now i can either do it uh it's
doing the you know so once i've defined
what my job is what is the function i
want to run
schedule says allows me to say all right
well every time period i can either say
every one minute
i could say every 60 seconds i can say
every hour every 24 hours
all i'm going to say is do job it's much
like
we've probably seen if you've done like
multi-threaded stuff in the past or
something like that
you define something as we do here
and then you say run it uh what schedule
does it says
run it every time frame run that thing
and so it's going to schedule that uh
it's going to go in and run it
and then all i need to do is i have this
little loop
that says that if i've got something
that needs to that is
waiting to be run then
uh it's gonna run it and so that's what
does what schedule does is it basically
cues it up and then i need to do run
pending to say run everything that's
pending
so i could you know conceivably
depending on how we do it i could have
something like i could have a couple of
different things that run
you know maybe one every one minute
every two minutes another one there's
every five one runs every ten hours
and then i could basically say well but
worst case i only want to run
any of those every five minutes and so
what i would do is i can say run pending
run every job that's out there that
needs to be run
and then sleep here is i'm going to say
just
you know since i don't want to keep
seeing if something's pending
then i'm going to just sleep for a
minute
and come back and check it
so that right there
i i created my job you know my thing i'm
going to do and then schedule itself
it's just a couple lines of code and i'm
off and running
now the way this script runs is it runs
through it says okay
first time i fire up i'm just going to
go ahead and
run these two functions up above which
is basically the job
so i could just now actually in the main
part of the script instead of doing it
this way
i could just say here i could just say
job
so i'm going to define it and i'm going
to run it and then i'm going to schedule
it and i'm going to run anything that's
pending i can do that or i can just say
forget that i'm not even going to run it
um
then i'm just going to come through here
i'm going to define it i'm going to
cue it up and then i'm going to run it
and so what we'll see here and we've
seen this actually
as we've been running through this today
if i
run let me do this let me clear that so
it's a little easier to see
when i run it um
did i miss something there date time
time has no attribute sleep
so oh i'm sorry because i had
a date time time but i also had up here
it was just called import time itself
was the one that
it's a different time where was that
uh
there we go import time okay so that's
what i thought it was
my mistake there is actually
i needed my i needed time itself because
you can do the
time function from date time but
there's also the time library which can
sometimes be a little bit complicated
but the one allows me to do sleep
uh let's see yeah
so now i'm gonna come in here so what
happens when you change stuff on the fly
so now oh it's because i need to
uh my mistake and because i have those
two it's going to be whichever one i
call last is going to be the problem i
wonder if i'm using
the date time time at all
i think i'm actually good so i think i
can actually get rid of that one
let's see this is why usually you don't
want to do it on the fly but let's see
if this will work for me
there we go okay so i've cued it up and
now it's going to wait
and then it's going to end up waking up
and it's going to run
the pending job now notice this time i
didn't run it right away
i could have which a lot of times is
what you're going to do is you'll just
say
you know like here i would just come in
and say hey job
run it and then uh here it's just going
to do while true so i don't have
anything that is going to end this i can
you know i'm basically going to have to
either kill it
or i can actually background it and let
it run in the background and
periodically it's going to show me the
updates
and i'll flip back to this in a second
uh but that brings us to a point here
where you sort of wrap it up a little
bit
and go to q a while i go flip back over
there let me see is it run yet
nope i hadn't run yet so using the ping
and the request
classes we talked about those we uh
the those allow us to do that ping
or a get we looked at some of this
dynamic application of style so we had
the
the classes for up or down that we could
see
here you know we get those different
colors
we looked at the scheduler itself and
then we looked at a page
auto refresh and so with those um
you know that gives us our back end a
little bit of a clean up and now we've
got a very simple
uh little application that we could run
you know however we want to do it i
guess i probably shrink this down a
little bit even
we could have this thing running you
know in the background somewhere
either on our you know or we could have
this actually it could be a nice little
thing if you wanted to do
a page essentially on your on your site
whatever your site happens to be
you could hook up a couple of these
things and have it one of those you know
status kinds of things that you
typically see for example i think
maybe aws status will have it yeah
so you could see something like you
could build something like this
essentially and you could
actually you could do this and tweak it
uh for your specific
site so that you could you know for your
look so that you could have
instead of the ui that i provided here
you could do something like that that's
that that basically lists it
so that allows you a quick and easy way
to do that
let's see it ran i think so we can see
here yes so it's it ran so we've got
this scheduled thing
it ran through but we also can see where
it came back around
and it skipped a bunch of those sites
and then it just tells us job complete
and then it just it's going to keep
running in the background so now we have
our back end running in the background
we have our whoops our whoops that's our
foreground let me kill that off anyways
where did that go we have our foreground
doing its
every 30 second fresh refresh and so now
we don't have to touch anything
and it's going to tell us if a site goes
down
and there we go so questions and
comments
you know what interests me so much about
and
first off it great presentation and also
lots of thoughts that come from it but
what interests me so much is that you
know we have the power as developers to
really shure up a site in a way that
most
canned um canned you know whizzy wigs or
whatever
don't usually have you know right out of
the box um
i'm also thinking about this gives me so
many ideas of shoring up
you know the distributed architecture
with different types of techniques you
know
pinging different services running
messages through
the the pipeline to kind of then
intercept
you know it going out of the the top of
the funnel type thing um
just to confirm everything's up and
running that's that's really cool man
appreciate it yeah it's a it's a really
common
thing that's out there that i don't
think we usually don't think about it
too much
uh until something breaks and then
you're like man i could have probably
done something
uh and this actually i mean i ended up
building this
concept of an app a long time ago
because i just had a couple of sites
and this was back when it was a lot
harder to have a site that stayed up
you know it's just more common something
would happen to break a site
and instead of me i sort of got in a
habit
of every day when i'd start my day i'd
go walk through
my three or four little sites to see if
they were up
and make sure that my website wasn't
down and i said well that's sort of
ridiculous and so what i did is i just
you know built a little app that did it
and you can do you could actually expand
from this really easily
and quickly you could do something like
if the site goes down
um you know if i do a check and the
site's failed then i also send an email
out that says hey your site's down
you know i thought about adding that
into this but it got it would have
gotten a lot longer
and you know we could have gotten a lot
more complicated and i wanted to keep
this a simple app
but i think you can already see it
there's a lot of things that you can do
even with this to just have a you know a
quick way to monitor what's up what's
down
and like i said it'd be really easy to
add some notifications on top of it as
well
and it's it's just to me it's a good
example of where
within you know probably i don't know
overall maybe an hour or two
and you can have a full featured
application using python and django that
that has all of these pieces and you
know you're ready to go so it's not and
it's not even a
like a prototype necessarily or
something like that i mean it's a
you've got a full app that you can run
quickly you got a database behind it
you've got tools to administer the data
you know everything you possibly need so
good
other questions and comments this is
really good
rob i i like the quick and ease and the
administration side of it because
with the polling in that i could
potentially write use this
built the front end for my test
generator tool so that you can build
the test cases and actually run them
from the gui instead of having to
actually
write the script yeah
yeah well and actually um
i think i don't i don't know if you know
if you've seen this but that's
actually
one of the nice things and i may show
this at some point because we did look
at we did a little bit with python
testing
but it also with selenium which you've
talked about
uh it does allow us it has a python test
uh export as well
uh https developer oops i need one there
there we go um
that i can do let me just kick on it
click on a couple of things real quick
oh i'm not recording or am i yes i am
recording so i can take you know i think
this
probably enough you've seen this before
is i can take the normal
stuff i do with selenium and it does
have
an export to python's pi test
which is insanely i don't see that's in
downloads i'll just show that real quick
because i've actually been playing
around with this lately
for uh some scraping type stuff i did
that made it so insanely easy
using selenium stuff as you can see that
it's actually
you know it generates a real simple
uh python script depending on how you do
it and it uses the same stuff that
you've seen
i know that michael's talked about it
you know extensively as far as the web
drivers that are out there once you've
got it
uh python is a tool that has built up
real has built a nice framework to work
with that it's one of those just like
java and c-sharp
that you could do something
much more complicated is i could
actually use this i mean this is from
scratch but i could
and uses the pi test stuff but i could
actually basically steal
this code build a web driver and i could
actually use that
as part of my monitoring is i could get
something you know pretty complicated
um i can also like you said i mean i
could i could build something that runs
my test scripts and then reports it back
somewhere and then just ping that you
know periodically to see if the tests
failed um or i could even return it yeah
i can and i could add to it there's some
other things i could do right now we
just do pass or fail
i could uh within this i could actually
grab the value that's returned
uh in these you know like in this case
where i'm looking at what the value is
this return
oh let me save that save that off
and i could actually do something to
display that so i could actually have
that
display here you know maybe like last
return value or something like that so
you can
you can do a lot quickly uh like i said
and it does have it's
that's why i like to this is an
application as an example is it just
gives you a nice starting point
point where there's a lot of things that
you could you can you know
leap from this platform to
excellent other questions and comments
all right hearing none that brings us to
the end yet again
so as always appreciate the time the
feedback the interaction
um you know all of the the time that you
spent i know that we we spend it
you know it is self-focused and extent
because we want to
make ourselves better and our career
better but it is uh
all that time spent is also great as far
as the group is concerned we get some
you know having the comments and the
discussions it helps all of us
grow if you have any questions about
this or any additional information
as always email info developingware.com
is out there
we have the contact us form on
developmentor.com
we've got our youtube channel the
easiest way to go out there is just
youtube and just do if you do
developpreneur it will get you to the
developer nor
uh channel we got a lot of stuff out
there we've got literally
i think we're up to like 200 videos or
something like that right now and it's
just like it's growing by leaps and
bounds we're definitely over a hundred
um and then the vimeo we still update
that
somewhat regularly most this the new
stuff the most part is going to youtube
but
these classes uh the mentor sessions
still show up on develop
the developer nor channel on vimeo as
well and then we'll eventually end up on
youtube
and of course we've got the building
better developers podcast uh the easiest
way to get to that is
you know you can do your favorite
podcatcher whatever it happens to be
or if you've got alexa you can just say
alexa enable building better developers
and boom it will go out there and grab
it for you get the latest
uh episode of that as always our goal is
making every developer better
we appreciate the time you spend doing
that and
go out there and have yourself a great
[Music]
day
[Music]
you
Transcript Segments
5.16

[Music]

16.62

[Music]

18.96

okay

19.439

so we're gonna go into part two

23.119

of our python django example um a couple

27.279

weeks ago now a couple sessions back we

30

got through part one

31.199

it ended up being a little more

32.96

complicated than

34.399

uh we could handle in one session so i

36.48

think we'll be able to do it

37.84

in this one uh there may be a couple

40.16

there are some additional things that

41.36

we're not going to go as deep into that

43.2

we'll probably do better just to be sort

45.36

of standalone

46.719

kinds of other areas that we may want to

49.52

go into but

50.399

the goal was to basically take things

53.44

that we'd talked about

54.719

in about django and python in a couple

56.8

of prior

58.399

sessions and roll them into a nice

60.719

little application that we could build

62.32

and work on

64.239

and so that's uh that's what we're doing

66.24

here

68.479

now since it's been a while we're going

70

to start out by we'll take a look at our

71.6

app so far where

72.56

we're at sort of where we left off last

74.96

time around

76.24

and then we're going to talk about

78.24

django one of the key things here

80.64

is taking the django piece that we saw

82.88

for front end

83.92

for being able to use it really is a

85.68

really nice

86.96

object relational mapping tool and and

89.28

using it to do

90.56

data management things like that and

93.119

using it in a

94.24

headless environment so you know

95.92

flipping to the other side of doing a

98.4

non

99.2

something without a user interface in

101.04

front of it and some of the

102.64

little bits of things that you need to

104.32

do there

106

then we're going to focus on the back

108

end process of our application

110.399

and working through the various types of

113.759

responses that we had there

116.64

and so let's talk about what we had last

118.88

time around

121.04

the key to this application is this

122.799

going to be it's a way to

124.799

monitor sites and api endpoints we just

127.28

want something that's just a nice

129.039

application that allows us to take a

131.84

look at you know sort of just have

133.04

something that's

134.239

occasionally checking you know like

135.76

heartbeats or values or something like

137.76

that to make sure that our

139.84

our api is up if it's an api our website

142.48

is up if it's up

144.16

our page is returning what it's supposed

145.92

to return if we've got a web page

149.28

and we looked at this with two different

151.519

focuses one would be really just more of

153.28

a heartbeat or a ping

155.44

and then uh the other is something where

157.28

would be more like an api where we're

158.879

actually we want to

159.76

check a value you know return value we

161.76

want to do something more than just say

163.92

hey do we get a you know a response from

166.239

a web a url

167.68

essentially and um

171.599

look at we had a front end that was our

174.48

essentially our administration

176.08

and reporting side of it so we could

178.4

take a look at what's out there

180.64

as far as um and we could add a site

183.84

remove a site edit the settings for a

185.68

site

186.48

and then there's a back end that is that

188.72

really is that heartbeat thing that

190.159

periodically

191.36

you know wait essentially you know wakes

193.12

up

194.48

runs through the checks that it needs to

196

check and then updates everything so we

198

can see how our sites are going

203.92

uh let's see so let me i'll flip to this

207.04

first if i've got it nope it wasn't on

209.36

this one it is on this guy so this is

211.68

roughly what we built

213.04

um now we're gonna this is a sort of the

215.36

new version of it so we're gonna talk

217.04

about some of the changes have been made

218.879

uh but essentially what we've got is

220.08

we've got these various sites that we've

222.239

added

222.879

and we can see in some cases

225.92

let me just do an edit on this in some

228.08

cases we've got

229.28

something where we're looking for a

230.319

value and we've got a url that's

232.56

actually sending some parameters

234.959

and then we've got others where it's

237.04

really just a

238.08

ping like the developer nurse site we

240.879

just go out there and we just say hey

243.04

you know i'm gonna see is it alive and

244.72

if it is then it's gonna give us a

247.439

you know a success or not

250.799

and normally we just see either you know

252.56

there's a failure or the site is alive

256.56

so let's flip back here so that's our

258.959

front end

259.68

now the back end obviously not as

262.8

visually

263.6

interesting or anything like that but

266.16

what it's going to do is we've got for

267.68

all these sites

269.36

for each of these sites or addresses

272.56

that we've built

274.08

it's going to go through there it's

276.08

going to see basically it's going to say

277.52

hey do i need to run this do i need to

279.28

do a check against it

281.52

and then i'm either going to do a ping

283.36

or make a call to that site based on

286.56

the type of uh here basically

290.08

the type of call that i'm doing

294.96

and then i'm going to update to make

296.24

sure that i've got that you know it's

297.28

got the latest result

299.68

and then we're actually going to talk a

301.28

little bit about uh cron versus

303.6

scheduler because we've got a couple of

304.96

ways that we can do this

306.24

and python itself uh is even you know

309.36

more

309.919

rudimentary than it's not even a django

311.6

thing it's a python thing is they've got

313.36

a built-in schedule tool that may work

315.759

depending on how we want to do it may be

317.199

the better approach for us

321.12

so in setting up that script we talked a

324.16

little we just

325.199

very briefly touched on it last time

328

around

329.12

so this time i want to spend a little

330.08

more time we're going to talk about the

331.36

basics of the script

334.08

setting up the getting the django

335.52

settings into the script so that we can

337.44

utilize

338.08

all of that uh the models and

342

basically the database connection pieces

344.16

that django gives us for free

346.479

since we've already got those in the

347.6

django application we want to use those

349.12

in our script

350.4

and then we'll walk through you know

351.759

some basic queries and

353.759

a simple example of running the script

356.08

what it looks like and

357.28

what kinds of things are going to be

358.319

going on with it

360.88

so let's jump over to some code

366.08

and let's start with let me blow this up

369.52

a little bit bigger

376.24

so actually i'll start with the just as

378.24

a as a refresher so the models was very

380.639

simple the database model is very simple

382.72

we have sites

384.24

so each one of those things those boxes

386.24

we saw on the interface is a site

388.56

and essentially it's just got what we

390.4

saw you've got a name a description

392.319

the url that you're trying to hit and

394.56

then some information to keep track of

396.24

you know what was the last result

397.919

uh when did it last uh when was it last

401.12

updated

403.28

and then there's some lookup tables

405.28

related to those

406.56

so it's very simple data model

409.84

and when we jump over to this pop-up

412.8

thing that's driving me nuts let's see

414.319

put that there

415.599

um and so we're going to jump into our

418.96

our back-end script now the first thing

422.08

that we've got is the bringing in the

425.52

django

426.4

pieces and that's actually fairly

429.68

straightforward it's not

430.88

terribly complicated uh if you remember

433.759

we

434.08

set up here we have the set

437.28

django's got a default settings file

440.24

that it gives us and then we did make

441.919

some

442.56

you know some changes to it so that for

444.96

example

446.16

uh here we could use a mysql database as

449.919

opposed to a sql white that they

452.08

give us by default and then we connected

454.24

it to our

455.28

our database for this application

458.4

and we want to use those same settings

460.88

and so in a script

462.8

it's actually pretty straightforward

464.4

there's a a class

467.12

that's called settings and so we can put

470.319

in that we can pull

471.52

import from django.conf

475.039

and then it's it this import os os gives

477.759

us operating system

479.759

kinds of things that we can do some

481.36

access to that

482.879

and all we need to do is we're going to

484

come in and we're going to grab we're

485.68

going to set

486.24

actually set the environment for the

488.479

django settings

490.08

we're going to set it equal to our uh

493.44

our project and then our settings file

495.68

and this project was called monitor

498.72

and then and actually we can do this in

501.199

any order we want to essentially just

502.56

import but we import the django stuff

506

all of its classes and functions we call

508.639

django setup

509.599

and boom we're off and running so if you

511.68

wanted to utilize

513.12

the stuff that you set up for django

516.64

in a script then those five lines will

519.279

get you there

520.64

the only thing you'll have to do is just

521.839

tweak it based on your application name

523.919

and the settings file and then just make

525.6

sure that it's you know you

527.2

depend on where you run the script you

528.8

may have to

530.24

make sure that's properly in the path

532.8

but that's all you need to do it's a

534.08

couple lines of code

535.2

and boom you get the whole

536.8

infrastructure of django

538.64

you know available to you which is key

541.04

because that allows us to utilize all of

543.12

those models

544.32

that we use you know that we built out

548.24

now we've got um we've got a couple

551.6

different

552.08

imports here that i'm going to i'll sort

553.519

of touch on as we go

556.48

uh one of them is datetime and pytz

560.88

these are these are really the

564.08

these are key python date related

568.16

stuff for lack of a better term not to

570.16

get too technical

571.92

and what you do with those is you get

574.32

the ability to work with dates

576

date times uh do calculations and and

579.76

differences diffs between those uh

582.16

actually or

582.8

if you want to call it more specifically

584.24

as they do at deltas

586.64

and uh you see right here is that we you

588.959

can that pytz

590.32

allows you to do it's basically python

592.16

time zone it allows you to set a time

593.839

zone so you have a context

595.519

for your uh your times your date times

599.279

and your times

601.12

and that's pretty key so that you don't

603.279

end up just everything going to

605.12

um greenwich mean time so you can do it

608.64

to you know match whatever your your

610.399

local

611.279

system time is now the first thing we're

614.48

going to do

617.04

let me make sure i want to do that yeah

618.72

so we've got our we've got our basics

621.279

set up

622.32

we're connecting to django we've got

624.64

some basic time stuff here

626.72

so let's look at our ping uh

629.839

luckily that is insanely easy to do

634.48

because what we're going to do is we're

635.76

just going to use in our case we're just

637.279

going to use the operating system

639.04

ping and we get that

642.48

through platform when we import platform

646.56

it's going to get us a um it tells us

649.519

what operating system we're working on

653.2

and then sub process allows us to

656.079

actually call something

657.519

basically it's just you know hey make a

659.36

shell command

661.2

and so all we need to do in this case

663.2

for the ping is actually pretty easy

664.72

we're going to send it in

666.24

an address and then we're going to do

669.04

either a dash c or dash

670.64

in depending on whether it is a windows

673.36

operating system

674.16

or not and so then all we do is we just

677.36

build out our command

678.48

which the command is just you give it

680.64

the command this is the operating system

682.64

or the shell command so this is you know

684.88

so we do ping

686.24

we're going to send a parameter we send

688

it a value and then we're going to send

690.16

it

692.16

the hostname in this case which looks

694.32

like

695.92

if you do this it would be ping dash

699.36

in 1 and then i could do like https on

703.36

developer newer

706.24

dot com and i probably missed something

709.04

there

709.6

what did i mistype that oh i think it's

712.88

because it's a dash one

718.56

i bet that's it maybe not

721.68

so i maybe whoops nope so i missed one

724.72

there but basically what that does is it

726.32

says

726.88

and because i think i got that well that

729.04

should be

734.16

there it is i must have missed something

736

oh i'm sorry not dash c

739.68

i'm sorry n is for windows c is for not

742.48

so

742.88

whoops and basically all that does is it

744.959

says ping it one time

746.72

so go out check that one time and see if

748.48

you can find it

750.56

and apparently this one it doesn't like

751.92

it right now

753.6

and so all you do there is then you're

755.04

just going to return whether that call

757.04

was successful or not

758.639

and so that's our ping so when we're

760.32

doing over here

762.8

we're trying to see like for this site

764.72

is it alive

766.8

then all we do and this is uh we call it

768.8

heartbeat so we've got two different

770.16

types

771.04

we have ping as the heartbeat and then

772.639

data return is gonna

774.16

we're gonna do something more

775.2

complicated than a ping

777.279

and then all we need to do is set the

778.72

time amount how often do we check

781.36

and then we're off and running and so

784.839

here

786.72

we've got our ping and now let's look

789.76

down here search up to the bottom here

791.839

jump to the end in a little bit uh what

794.48

we do

795.36

is and this is a full script so there's

798.639

a couple things we're going to come back

799.68

to

800.48

but right now for the pings we're going

802.639

to call those heartbeats so we're going

804.079

to call this check heartbeats

806.639

and just note i guess that this is all

809.36

you know an inline script so this is a

810.959

function we've got the ping function

813.12

we create check heartbeats function the

815.04

check request function

816.72

and then we're going to come down to the

817.92

main part and we're going to check the

819.44

the heartbeats

820.24

check the requests and then there's some

822.48

extra stuff down here that we're going

823.68

to do that we will talk about later so

825.199

let's talk about the heartbeats

828.24

and since we're using the django

832.88

models this is really easy to do all

835.279

we're going to do

836.639

is we're going to use the model so we're

838.079

going to go to our sites

840.24

which is where did i put models

845.04

ah there we go so i'm gonna go into the

847.36

sites

848.32

and i'm gonna check everywhere that ping

851.6

is equal to one because that means that

853.839

i wanna try a ping

856.16

and so i'm going to grab all of them and

858.24

i'm going to filter it by ping id

859.68

equals to 1. i'm going to go ahead and

862.56

this is where i'm using that

864

utc time i just want to get my you know

866.24

what time is it now

868.24

and i'm using this date time it's pretty

870.48

straightforward

873.839

it's just a today which is probably

876.32

pretty

877.199

familiar if you're dealing with date

879.12

time stuff anywhere

880.88

almost every library framework has

883.839

either

884.32

now or today or something like that

888.24

and so that's we're going to do is we're

889.36

going to take the today we localize it

891.68

to

892.16

because i'm on utc i'm going to localize

894.399

it to that and that's equal to now

896.56

and so i'm just going to walk through so

898.56

i list i've got all my sites that were

900.24

returned

901.12

from this query and i'm going to walk

903.92

through each one and i'm just going to

905.04

say for each of the sites

907.04

then i'm going to see if the last time i

909.199

checked it

910.24

is either empty or

913.6

it's equal to or i'm sorry actually the

918.16

last time i checked it plus whatever the

920.72

frequency is

921.92

and that was and the frequency is how

923.76

often do i want to

926

uh what is the period of time between

927.92

checks so if it's every five minutes

930.48

it would say when was the last check

932.48

plus five minutes

934.16

is that less than now so is that already

936.8

passed

937.6

if it's greater than that amount now

938.959

then that's in the future

940.88

so we basically say hey if we've never

942.88

checked before then we're going to go

944

ahead and check

945.12

and if we have we just want to see where

947.279

that time frame sits

949.759

and if we do need to check it

953.12

so if we don't we'll take that that's a

954.72

short path we're just going to say we

956

skipped it so we'll see that

957.6

come out that we just skipped that site

960.32

otherwise

961.44

uh we're going to grab the host out of

964.16

the

964.56

um out of the data for that record

968.72

and then we're going to ping it and um

972.24

all we do we actually don't need for the

974.079

ping which is where i had the problem

976.24

before is i don't actually do the https

979.04

colon backside backslash i'm going to do

981.199

it without that

982.399

and so then i'm going to get my ping and

985.36

so that results

986.639

i'm going to grab the result from the

988.079

ping oh i'm sorry

991.279

first i'm going to go to my various

993.36

results and basically i either have

994.959

it's either fail or the site is live

998.72

and so i'm going to check i'm going to

1000.16

go grab my fail

1002.16

object because i'm actually getting

1004.32

result that's

1005.519

the result that i get back from ping is

1007.199

actually going to be potentially an

1008.959

object

1010.48

um and so if the oh i'm sorry

1013.92

it's not it's just a zero one but what

1015.44

i'm going to do is i'm going to say if

1016.56

it

1017.519

is a one so if it's true basically

1020.88

then i'm going to set it equal to the

1024.559

uh the live object and this again

1027.839

remember that we're dealing with

1029.679

uh we're dealing with the model the

1031.36

attributes are actually

1033.12

objects and not always uh not

1034.959

necessarily an id when you're working

1036.48

within the django world

1039.36

so i have a last result

1042.799

since it is here since it's a foreign

1044.64

key on lookup result

1046.959

although i can go in and just do it by

1049.679

id what i really want to do

1051.12

is do it by class so i'm just going to

1052.72

grab a lookup result

1055.12

value and shove it into last result

1058.48

and that's what i do here is i go in and

1060.32

i do look up results

1062.4

and i'm going to do a get where the code

1065.44

is equal to

1066.08

live and let me um

1070.16

let me switch gears just a second here

1076.24

and open up the admin side

1081.52

and so we see here is that i have um

1085.36

for my results there's four different

1087.36

things that are out there that i've got

1088.72

in that lookup table

1090.32

and i don't have an actual really that

1092.88

i'd care about i don't have an actual

1094.32

numeric

1094.96

id but i do have if you guys remember we

1098

have these

1098.559

unique codes so that's what i'm looking

1101.28

for i'm either going to grab the live

1102.88

code

1103.76

or the fail code and if the result i get

1107.679

back from the ping

1108.64

is true then it's live otherwise

1112.64

it's going to be fail and then all i

1114.4

need to do

1115.76

is i'm going to set the last result

1117.679

equal to whatever this result is

1120.32

i'm going to say that the last time i

1121.919

checked it was now because i just

1123.679

checked it

1124.559

and i saved that record and all of this

1126.72

i'm i'm utilizing

1128

through these three things i'm utilizing

1129.76

django's model stuff

1131.52

to allow me to quickly you know with a

1133.44

few lines of code be able to do all of

1135.28

that

1137.2

so now if we look let me open this up

1140.96

just a little bit

1142.799

so if i were to run this monitor this

1146.559

thing called monitor engine all i need

1148.559

to do is it's just a straight python

1150.24

script

1150.72

so i'm just going to do python and then

1152.64

i'm going to send it the script that i'm

1154.4

running

1155.28

so when i run it what we'll see

1158.799

is right now it's kicking out i'm going

1161.84

to see the results

1164.16

i'm sorry the the uh since i'm sending

1166.799

this command

1168.08

and let me see where did i run it here

1172.64

somewhere up here here we go so then

1174.96

what it is i'm going to see each of

1176.48

these pings so i'm pinging and i've got

1178.64

multiple sites

1180.559

you can see here that i've got multiple

1184

sites that i'm

1184.96

i'm doing checks against now

1188.48

i think this one and this one and this

1190.799

one i think i've got three

1193.6

three are just pings yeah there's a

1196.08

heart three are heartbeats

1197.679

and then two are gonna be uh looking at

1200.4

data returned

1202.159

and so if i look at those three

1203.44

developing or rb consulting in my time

1205.84

matters

1207.52

oops i'm going to see each of those when

1210.799

it's going to go out and try to hit

1211.84

those

1212.64

and so it's actually giving me here

1216.48

so let's see so this one is

1219.48

developmenture.com

1221.2

it does rb sns and it does my time

1224.64

and then it's going to come in and it's

1226.96

doing the others we're going to look at

1228.24

later

1230.24

now if i run it again up and actually

1233.2

since right now i've got it scheduled to

1235.2

keep running let me change that real

1237.28

quick

1239.2

pull this out

1245.6

okay and i'll come back to that in a

1246.84

minute so this time

1249.36

because none of these have uh the time

1251.76

hasn't passed for each of these

1253.28

then it's just going to skip each of

1254.64

those sites because i've already

1256.64

hit each of those up so in each of these

1259.12

cases

1260.159

we can see where uh the frequency was

1262.96

you know

1263.84

it hasn't been long enough for me to

1265.36

want to do a heartbeat again

1267.2

so this is where our general engine for

1270.24

the application is going to work is

1271.6

we're going to kick this thing off and

1272.88

let it just run regularly

1274.64

like for example every minute and if it

1277.28

runs every minute

1278.96

then when it runs it's either going to

1280.799

skip stuff or

1282.72

it's going to update some of these

1284.08

things and so we can see here like

1285.76

developing or it just updated again

1288.32

and then on our site on our front end

1291.679

we're going to see where each of these

1294.559

uh where we get

1295.44

our last update and so we can see for

1299.2

like

1299.679

example this one this rv consulting is

1301.84

more frequent apparently because it

1303.36

updated

1304.08

on 351 where the other ones did not

1311.2

and so that's our i think that's what i

1313.679

cover for this one

1318.159

so that'll go so for now that's our

1321.52

initial piece here i'm going to come

1322.72

back to this but i wanted to

1325.039

get us through the most general version

1328

of the application

1330.159

particularly the back end

1333.44

so we've talked about whoops uh yeah

1336.559

there we go so we've talked about ping

1338.88

and so that one was pretty

1340.32

straightforward we're just gonna we're

1342

just gonna hijack the operating system

1343.679

ping

1344.24

so you know it's already there why not

1347.52

now uh jen or python actually gives us

1350.88

a nice way to do our gets and posts and

1353.84

things like that so we're going to work

1355.12

on a get

1356.96

we're not going to get into posts and

1358.48

puts we probably could if we wanted to

1360.4

but it seems like that would be

1363.44

a little bit complicated you probably

1364.88

want something that's you're really not

1366.159

going to do that as a heartbeat for a

1367.52

site if you're doing puts in posts

1369.6

then you're probably updating data and

1373.52

although you can do that as a test i

1375.76

would think you probably would not want

1377.12

to so we're going to keep it simple for

1378.559

this

1379.28

this type of application and so we're

1382.559

going to

1383.44

now switch gears a little bit from the

1385.36

ping to get and then with git we're

1387.2

going to get a response

1388.72

and we're going to look at a class in

1390.72

python that allows us to to work with

1392.64

that fairly

1393.679

simply and straightforward

1397.2

so now so we did our heartbeats let me

1401.2

shrink this where is that at let's

1403.84

shrink that down a little bit

1406.32

so that was heartbeats that's going to

1408

go through everything that

1409.76

is looking at the heartbeat side but now

1411.52

the other option we have are requests

1413.6

and this is where we're going to

1415.6

actually be able to look at a value so

1417.52

for example

1420.08

we're going to have um in this case

1423.76

we're just hitting our our server which

1425.84

is this thing

1427.12

and we're going to hit it with an

1428.4

address that we want to actually see

1430.559

what is the result that's coming back

1432.32

and we're going to check this every five

1433.919

minutes now as an example i want to go

1436.64

look at that let's see

1440.32

create a window if i go hit that this is

1443.2

what i'm going to see

1444

normally got something very simple and i

1446.799

built this

1448.72

this and the other one i added two

1450.4

little

1451.76

test urls to my site so

1455.039

hb is just this heartbeat and this is

1457.679

something you may want to do

1459.919

for your site i've seen this a lot of

1462.4

times where instead of just

1464.48

essentially doing a ping to make sure

1466.88

something's available

1468

and you would you would use this a lot

1469.6

where you've got

1471.039

for example like maybe an api that you

1474

want to see if the back end is

1475.52

up and you've got a some mobile apps

1478.08

that are hitting it then maybe the first

1479.6

thing they want to do is do some sort of

1481.2

a status check against the api

1483.6

in general and so maybe you would have

1485.679

like a heartbeat call or something like

1487.36

that

1488.08

that sends you know something back it

1490.72

may be just something like hey i'm alive

1492.72

uh sometimes you'll see and you'll get

1495.279

this actually go out to some

1497.2

major apis and they actually have status

1499.12

pages

1500.559

and so they may break this down so it

1502.08

may be you know the site is responding

1503.52

and they may have

1504.4

uh you know front end is up back end is

1507.919

up um migration

1510.96

tools are up you know something back up

1513.6

is down

1514.24

you know something like that is that you

1515.52

may have actually something pretty

1517.039

complicated that you'd want to check

1518.48

against

1520.4

and so we just to sort of give a an

1523.039

example of that

1523.919

as opposed to having to build out you

1525.84

know walk through a little api example

1527.6

i just added these into this site so

1529.76

it's pretty easy for us to

1531.36

to play around with them for setting up

1533.44

stuff locally

1534.559

so i did hb and then i did this other

1536.48

one that's just m which takes

1538.24

two values and multiplies them and so

1540.96

that one

1542

uh here whoop let me go back here

1545.52

so what i did to test it

1548.88

is i'm just going to give it 3 times 6

1551.919

and then the value should be 18 and this

1554.08

would be much more like a

1556.4

an api kind of call where i would do

1558.64

something like this

1560

and then i should get a value back

1563.279

so i've added those two in for us to

1566.159

play around with

1567.12

this second piece and so now let's take

1569.76

a look at that

1570.64

uh and just actually i guess just for

1572.72

clarity we'll just walk through those

1574.159

real quick

1575.919

uh let's see so heartbeat

1579.52

uh i think we've talked about this

1580.799

before but in both these cases all i'm

1583.039

doing is i'm just i'm not going to our

1585.2

normal

1587.679

normally what we're going to do is we're

1588.799

going to build some values out and we go

1590.4

to our html

1591.6

essentially our template pages so if i

1594.559

look at

1595.36

this page in the django world

1598.559

it's siteless so if you remember i've

1600.48

got this thing where i've got these

1602.08

content blocks and then i've got some

1604.64

html that i'm

1605.76

basically building based on that

1609.52

and in this case go back to

1612.18

[Music]

1613.52

go back to my views here we go

1617.12

in this case instead of rendering

1620.48

as we do with html i'm just going to

1622.4

build out a raw

1623.84

http response and we see that when i did

1627.2

the heartbeat is all i did is i just

1628.96

sent it a string

1629.84

and it kicked it back and uh in the

1632.88

multiplier

1633.919

i've got my two values and i just

1636.32

multiply those out

1637.919

now i can do something you know

1639.679

complicated i can do

1641.679

uh hello world

1646.08

and if i change that and go back to

1652.84

heartbeat

1654.88

then now i'm just sending it and it's

1656.88

just like you can see

1658.32

it's just raw html

1661.679

of course now if i do that and i run my

1663.84

monitor

1665.36

then i'm going to see

1669.76

here that heartbeat failed

1675.279

and this is something actually that we

1677.12

i'm going to talk about in a second but

1678.24

we did change this up a little bit

1679.76

we clean this up because last time these

1681.44

were just straight

1683.039

uh backgrounds so actually now i've got

1684.88

something that's a little more

1686.32

colorful we'll take a look at that in a

1688.08

second or a few minutes as it were

1692

and let me kill that so that doesn't

1694.399

just continue to run

1697.279

and now we so we can build our response

1699.679

and we can do whatever we want to

1701.84

uh as part of that response

1706.159

it's really nice for again we don't need

1708.799

to have a full-blown

1710.399

an actual api although we have looked at

1713.279

that in the past

1714.799

we can do something like this and just

1716.88

you know have some values some urls that

1718.96

we build rather quickly

1720.559

you know it's just hey this is what i

1721.679

want the arl to look like and then we

1723.84

can

1724.24

you know force a response out that

1726.08

doesn't have to be we don't even have to

1727.6

build our html page

1729.44

we can just do something just a straight

1731.76

response

1733.12

so let's go back to our

1736.559

our primary engine here

1739.6

now before uh if ping is equal to one

1743.679

uh and this is the ping id which i could

1745.76

have grabbed

1746.799

the uh ping value but i just kept it

1750.32

this is an example where we can send a

1752

class

1752.72

like we did here or i can just go in and

1755.6

say

1755.919

just directly you know i'm going to cut

1758.64

to the chase and i'm going to send an id

1760.96

and i know that my two ids and i'll look

1763.919

at those real quick so

1765.039

the ping types are either data returned

1767.84

or heartbeat

1769.919

heartbeat has an id of one you can

1773.2

barely see it there

1774.88

which technically i would never need to

1776.559

see i probably should do it

1778.64

by heartbeat code here like i did with

1783.44

my lookup result but i just wanted to

1785.84

show that's

1786.48

it's cleaner to use it by code and more

1789.44

uh

1790.24

resilient because if for some reason the

1792.08

actual id of that record changes

1795.36

then that would break it but i wanted to

1797.679

show that you can

1798.64

actually just directly instead of doing

1800.88

it by ping

1801.679

i can use an underscore id and then just

1803.52

send an id value across

1807.36

um let's see and so i oh here we go

1810.799

so check request before i did it where

1813.76

the id is equal to one this time

1815.44

so do the same thing i'm going to grab

1816.799

my sites where

1818.48

now instead of the heartbeat i'm doing

1820.399

the value

1821.76

i still use that now that i used it

1823.76

before

1825.52

so i get the current time stamp what is

1827.44

it today right now

1829.36

and then i'm going to watch through walk

1830.559

through each site and essentially the

1832.96

same thing i'm going to say hey if i

1834.32

haven't checked it or

1837.279

um well that's neat i used

1842.88

i didn't need i don't know why i doubled

1844.24

that up but there you go

1845.919

uh or if the last check was

1850.64

since uh was more recently than i want

1854

to do my

1854.96

uh period my period of checks then i'll

1857.76

skip it

1859.039

um i'm sorry or if it

1862.159

if it is within the frequency so if it's

1863.919

longer than the last frequency or

1865.6

it's empty i'm going to do something

1867.039

otherwise i'm just going to say skipped

1868.48

it

1869.76

which we saw before now before we had

1872.48

the ping

1873.44

this one's actually not much more

1875.919

complicated

1877.2

now here i've got some prints to show

1879.519

the

1880.24

result text and status code

1885.36

which i think we can see here so

1888.559

for the ones that we've seen so like

1891.2

here if you can see the latest one i did

1893.84

is it actually kicked out this was the

1895.6

text of the

1897.12

of the result and this is the http

1900

response

1901.679

and so i can check for thing because it

1903.279

could be like here it's a 200 but it

1904.96

could be a 400

1906.08

a 401 a 500 you know all those other

1909.279

typical responses now i can

1913.36

if i want i can say that for

1916.799

these these uh value checks that i want

1920.159

to make sure that i do have a 200 plus

1923.279

a value but i'm keeping it pretty simple

1926.24

in this case

1928.799

and i'm just going to say that if it's

1931.919

not a 200

1933.679

because we're just doing it basically

1934.72

it's either yes we're getting something

1935.919

or no we didn't

1937.6

um so one of the things we're going to

1939.519

do is first we're going to see

1942.799

well actually i sort of messed with this

1944.399

one a little bit but this one

1945.84

first we're going to see is the result

1950.799

here so i'm going to get result is the

1953.84

actual result by default i'm going to

1956.64

assume it's a fail

1957.76

otherwise if the desired result is equal

1959.919

to 3

1961.2

and this is oops this is where i've got

1962.72

two different versions of this value

1964.399

check

1968.399

so it's either the simple response or

1971.12

the value response

1972.559

the simple response says is it a 200.

1976.32

the value response says i'm going to

1978.32

give you a value

1979.36

and i want to check against that

1983.039

and we see that uh let me go back to my

1985.84

admin

1987.36

and so here for heartbeat

1990.64

this is the value i'm checking against

1993.2

if i wanted it to just be

1994.799

a simple response then even though i

1996.88

have a value it's not going to care what

1998.72

that value is

2001.84

and so it allows us you know we've got a

2003.44

heartbeat which is a ping

2004.88

we've got a get which is the uh simple

2008.399

response and then we've got the value

2009.76

response that says not only am i going

2011.6

to do a

2012.32

http get

2015.679

a web get i'm also going to check a

2017.44

value that's returned

2020.399

hey rob good question yeah um go back to

2023.76

your other screen for a moment

2026.159

uh the listing screen yep this one no

2028.88

right there okay

2030

so i'm assuming there's a way in

2033.12

uh django to do this but uh is there a

2035.44

way that it

2036.799

based on your drop down will hide or

2038.88

show that

2039.84

desired value uh

2044.08

what do you mean it's so that

2047.279

oh oh so like if i do this it would

2049.28

either hide or show this

2052.079

yes and it's not actually uh that's

2054

actually at that point it's not a django

2055.44

thing it's really it would be a standard

2057.76

javascript thing

2060

so what i would do um and this it

2063.839

that does get a little bit tricky

2066.48

because i think this is uh let me go

2068.079

back to that

2068.96

that's a good side question uh if i go

2070.8

to the list i think i'm using a

2072.839

form um

2076.879

no i'm not uh let's see am i using a

2078.879

form no i'm not so what i would okay

2081.2

what you would do is you would okay so i

2083.599

get now so you

2084.56

update it here based on

2088.32

so it this would check ah yeah there it

2090.48

is okay so you got if code in there all

2092.159

right

2092.48

yeah i was trying to follow this earlier

2095.2

uh

2095.599

and you kind of went a little faster but

2097.359

i i see it now okay

2099.2

cool yeah so so what i could do yeah is

2101.359

and i don't think i had any of that

2103.599

built in but yes so i could do that and

2105.599

just say based on that value that these

2107.2

things are going to be

2108

visible or not um and

2111.2

yeah django doesn't give us anything

2112.96

special on that but it's

2114.96

it's actually it's now we're just down

2116.8

to you know standard

2118

uh web stuff at that point

2121.599

so good question right yeah yes so it

2124.88

kind of looks like it's a

2126.4

so the way django does the web displays

2129.04

it's kind of like a jsp

2130.8

or um you know the jstl tag precisely

2134.32

precisely is it's it's really there it

2137.28

add

2137.599

it gives you your um more like a

2140.56

template

2141.44

essentially and it gives you some you

2143.04

know like jsp or

2144.8

asp or any of those it gives you a way

2147.44

to do some tags

2148.72

but then the rest of it is your you know

2150.72

you're building it into your

2152.16

your page itself and you can build and

2153.92

then you can include

2155.599

um like here you know you can build

2159.2

um you can you include javascript as

2161.76

needed

2162.72

and it's just gonna yeah it's gonna spit

2165.2

out your html on the back end

2168.16

okay cool thanks that answer from the

2169.92

question good question

2173.119

all right so

2176.64

uh so back to that so we've got our two

2178.72

different things we're either going to

2180.16

say

2181.119

if my result and this is again that's a

2183.76

good example here

2185.28

of where while i can use my ids it is so

2188.24

much easier to read

2189.68

if i'm building it based on like a

2192.64

readable code value

2194

so desired result equals the three

2196.96

actually

2198.56

if we look here is going to be i think

2200.72

that's the value response

2203.28

yeah this value response so it would be

2204.96

easier if i was actually doing code i

2206.8

would at least see value

2208.32

or i could do it by the name so that's

2210.32

something much more

2212.96

developer friendly instead of what is

2216.079

almost effectively a magic number

2218.16

because it's like i don't know what a

2219.76

id3 is unless i go back and look at the

2222.64

database

2223.52

so while it may be a shortcut in a sense

2225.839

for me to do this as an id it really

2228.64

is not as good maintainability wise

2233.04

and it is a little i guess it is a

2234.24

little bit faster because i'm not

2235.68

grabbing that object

2237.52

so there is that there is a cost there

2239.119

but you could do some of this stuff

2240.4

where

2241.119

i don't have to you know i can actually

2242.88

get a couple of these objects and cache

2244.4

them off at the start

2247.04

but i digress so here we are either

2249.92

going to check the value

2250.96

in which case we've got the two things

2253.599

we can look at

2254.32

is we either have results status code

2256.24

which gives us the status code which is

2258.48

you know 200 400 401 500 501 or whatever

2263.2

we check against our status code and we

2265.04

can say if we're checking that

2266.24

we just say if it's a 200 then we're

2267.839

live that's what we're using for

2270.079

our evaluation otherwise we don't care

2273.599

what the status code we actually care

2275.04

what the text is that's sent

2277.92

and then we want to make sure that um

2282.4

oh and we want to make sure that that

2283.76

text is equal to

2285.44

the text that we say it should be in

2287.599

which case

2288.64

let's go back over here this is the text

2291.52

that we say it should be that is our

2293.28

desired value and then we go back the

2296.88

same thing we did with the paint

2298.72

is again it's like okay whatever the

2301.04

last

2301.839

result is is going to be either live or

2304.56

failed that based on what we got

2307.599

we're going to set our last check time

2309.04

to now and then we're going to save it

2310.72

and then we're off and running so now

2313.359

and this goes back to what we

2315.2

had before let me get rid of this guy

2317.52

real quick

2321.76

and so now what we're going to be able

2323.76

to see

2325.04

let me get that is that we're going to

2326.88

go through and we're going to check

2328.72

for where did i run that here so i ran

2331.52

it

2332.16

and i'm going to do it's going to do a

2333.839

ping it's going to do another ping

2335.76

it's going to do another ping and then

2338.32

it's going to come through it's going to

2339.52

walk through and do the heartbeats but

2341.119

since i've got

2342.24

no printouts based on that right now

2345.599

it's only going to tell me if it skips

2347.04

it

2348.48

so here if i run it again

2353.04

then we're going to see where i have my

2355.04

three pings

2356.64

and then i have my two others and it's

2359.599

going to run those but it skipped those

2360.96

because it

2362.079

caught them last time

2367.2

so let's take another step on our uh

2370.4

interface and talk about that a little

2372.079

bit and then i'm going to talk about

2373.2

this the python scheduler

2374.72

to just uh essentially to clean this up

2377.52

because right now

2378.88

the way we've got it you can see is i

2380.48

have to manually run

2382.48

this engine each time or create a cron

2385.52

job that mainly runs it

2387.04

you know each time and

2390.72

the interface that i'm showing you right

2392.48

now is not quite

2394.16

uh was not what we had so i want to talk

2396.079

a little bit about how i've

2397.2

uh updated this let's make sure yes

2400.32

everybody's

2401.04

running right now and so i'm going to do

2404.64

a page refresh

2405.76

on this page so that i don't have to do

2408.24

a you know force a refresh every time

2410.8

to see how my sights are doing i'm going

2413.28

to change some background colors and

2414.88

look a little bit about that in the um

2417.839

and how we can do that in css it's a

2420

little bit of a slide trip but

2421.599

you know just to show a nice easy way to

2423.44

do this from css

2424.88

and we're going to talk about scheduler

2427.52

uh the nice thing about scheduling

2428.96

we're going to see it's really easy

2432.24

it's very easy to set up it's really

2434.72

easy to create a job schedule the job

2436.72

and then run it and sleep as needed it's

2440

it's like cron but it's probably even

2441.68

easier to understand than kron

2443.44

so it makes it a really nice tool which

2445.839

is why i want to make sure i cover that

2448.4

within this application and it does sort

2450.48

of round out everything so when we're

2451.839

done

2452.56

today we'll have an application that we

2454.16

could you know spin up and run and

2456.56

set up some sites that we want to work

2457.839

with and we're we've got a little

2459.76

monitor app going

2464.24

so one of the first thing and this goes

2466.4

back a little bit to the question we

2467.92

just had

2469.44

is one of the things i want to do whoops

2472.16

with

2472.88

my site is make it so that this thing

2476.64

doesn't force me to do a refresh is i

2478.96

want to just do an auto refresh and this

2481.04

is not a new

2482.319

trick but one that i want to make sure

2484.88

that i mentioned

2486

everybody so this is my site list

2490.079

page this is site list

2493.92

sites goes to sitelist.html

2496.96

and if i want to do a refresh it is

2500.079

literally

2500.72

that simple is that you can tell your

2502.72

page to do a refresh

2504.48

you tell it how many seconds uh

2507.92

how frequently you want to do it and

2510.24

then you're off and running

2511.839

so if i want to do it every second then

2515.119

i can i'm gonna have to refresh it once

2516.96

so i get that new value

2518.4

and now you're actually gonna see maybe

2519.92

you can see here it's actually

2520.96

refreshing

2521.68

every second so if i go in and run my

2525.839

well actually and i can see here's the

2527.04

back end where i can see it's just

2528.72

making this call

2529.68

it keeps making this call and

2532.72

if i turn on the update

2536.88

then what i'm gonna see is now there's

2538.96

probably a couple yeah so like here

2541.44

it's already changed its time and if i

2543.92

wait for a minute or two

2545.359

it's gonna you know it's gonna pick that

2547.52

back up so let me turn that off so it's

2549.52

not doing

2550

it every 15 sec or every second because

2552.64

honestly

2553.52

um and actually i can do it every 30

2555.599

because the frequency the most

2557.52

frequent check we have in our

2558.8

application is one minute

2560.72

so i'm going to do it every 30 seconds

2562.4

i'm going to do an update i could do it

2564

every minute but

2565.119

every 60 seconds but i may miss one so i

2567.599

figure

2568.319

i'll just do it every 30 seconds for now

2570.24

and it's a local app so it doesn't

2571.92

matter too much

2574.8

so in doing that and now uh it

2578.24

you know since it was updating every

2579.599

second it hit an update

2581.599

now it's going to update every 30

2583.28

seconds

2585.28

and i'm going to see at some point i'm

2586.8

going to see these guys

2589.2

update so that's a refresh on the page

2593.28

another thing i want to do

2594.96

is be able to change these so i can see

2596.96

if something is up or down so let me

2599.119

actually um

2601.28

[Music]

2602.72

let me break a couple of these so i'm

2604.48

going to say 3 times 6 is 19

2607.92

and i'm going to say hb i'm going to

2609.76

give it something else

2611.119

to check for so those two are going to

2612.64

start to fail on me

2615.839

and what i want to do is i can see let

2618.56

me go back here as right now i see green

2620.96

but what i want to do

2621.92

is be able to see you know have

2623.599

something that's red if something's down

2625.28

and i could change these colors to a lot

2626.96

of different

2627.92

things which basically is either going

2630

to be here it's either the normal one

2632

for

2632.48

that i've got for my style sheet or my

2635.04

class it's either

2636.24

site or site down that's just the two

2639.68

things either it's up

2641.2

or it's down now all of these right now

2642.88

are up at some point it's gonna check

2645.2

these two guys and they're gonna go down

2647.92

and

2649.119

the easiest way to do that of course is

2651.599

css

2652.4

which where did i put my css here we go

2655.839

and actually open site and site it's

2658.16

actually site up inside down so let's

2659.68

just do

2660.839

that

2665.04

let's see if i go back here oh i think i

2666.96

had it oh i'm sorry

2669.44

is i have that it's either side up or

2673.44

site down and then i think if i create a

2675.04

new one it's going to actually pick up

2678.4

um the site itself so if i create a new

2680.64

one so here

2682

i can see now these two are down because

2683.76

i broke those values

2685.44

if i add a site i'm just going to add a

2688.4

site real quick

2689.52

that is heartbeat

2698.24

if i just just do that

2702.839

oh and i want to do this

2705.68

minutes

2711.2

uh simple response there we go

2714.24

so here it hasn't checked it so i can

2716.319

see this guy

2717.28

actually is gonna be uh he's got no

2720.16

color

2721.599

so this means i've never checked it this

2723.119

means it's alive this means it's failed

2725.68

and so i've got three different statuses

2727.68

basically for

2728.88

a site right now that's uh based on

2730.96

color

2734

and so that is either site upside down

2736.16

or just the default site

2738.4

and we had already the default site

2741.599

that we had that thing built up and so

2744.24

all i do

2745.359

with site up is it's going to be i can

2748.56

essentially just copy and paste it and

2750.24

i'm just changing

2751.28

some colors so i can see here uh let's

2754.4

see that the

2755.359

background color i changed that over

2758.56

and if you see oh this one's not down

2760.56

but uh before

2762.319

the text was it was a light i had a gray

2764.96

with a black text

2766.88

um it's the the forward the primary

2769.839

color

2771.44

well when i flip it i want to change the

2773.44

text to white so it shows up in that

2775.68

that green or that red and so really all

2777.839

i have to do is change background color

2779.359

here

2780.88

and let's see whoops and so that's for

2783.839

site up

2784.56

site down i'm going to make it red and

2787.92

boom i'm

2788.64

you know i'm off and running as any one

2790.24

of these i can pick that up

2794.079

and so now we've got a little bit more

2796.48

um

2798.319

visual you know interface you get a

2800.319

little better user experience because

2801.68

now i'm seeing

2802.56

those colors in there and like i said

2805.44

again this is where

2806.64

if you do stuff following your standards

2809.44

you know throw some uh

2811.04

use your css classes like we did you

2813.2

know from the start

2814.88

we had uh wait on the site list from the

2817.76

start we had the site

2820.72

class so that we were able to do some

2823.2

styling on these

2825.839

and so once we've got that then you know

2828

we're essentially we're off and running

2829.44

now i do

2830.16

want to say that i think i had site

2834.72

and i think i had another one let's see

2836.72

if i look at site

2838.56

box i got a site hover yeah so i had hi

2841.599

site hover and uh you may have seen that

2844.8

that actually does

2846.16

a little bit of shading and what i can

2848.559

do is i can actually do that

2852.079

take that same thing actually i'm going

2853.92

to move this here

2858.16

and if i want to get my site hovers for

2860.079

those then i can do site up and site

2862.079

down

2862.48

i'm going to do the same thing and

2865.839

i did like a site yep and that's just a

2869.98

[Music]

2871.599

so i'm strange up here and i'm going to

2872.8

do the same thing for site up

2877.599

and oops and sight down

2886.16

and right now i can see that's nothing's

2888.319

nothing happens on my hover

2891.92

oh in this case because it's a css it's

2894.319

a static change and i need to restart my

2896.4

server so it's going to pick that back

2898.839

up

2900.079

and now i should see on a hover but you

2902.96

can't really see it

2905.44

i make sure i got that right set up

2908.4

hover

2909.599

hover side down hover side down hover

2914.88

and i think i did not oop let's make

2917.76

sure i've got that right i may not be

2919.839

refreshing it right oh because it's not

2921.76

gonna

2922.16

i needed my mistake i need to jump to a

2924.72

new

2925.599

window because it's already cached that

2928.559

so let me instead

2930.64

move to a private window so it doesn't

2933.92

hold it and this should

2935.359

pick that up do my login

2940

gotta enter my password right

2944.24

and so now you probably can i don't know

2946.4

how well you can see it

2947.76

but now it's gonna pick up

2951.599

my hovers here so all that real quickly

2954.319

through

2954.8

css which again goes back to just like

2957.04

one of those nice little things that

2958.319

says hey

2959.44

you know make sure where you can use css

2962.64

classes and it makes your

2964

one it makes your interfaces a little

2965.599

cleaner uh you don't have these like

2967.76

special you know fonts and other things

2970.559

that you need to do just drive it

2971.92

through classes

2972.96

and then when you want to change the

2973.92

look and feel quickly then you can do it

2976

here so if i wanted to do

2977.839

like real quick and say that i don't

2980

like

2983.04

red i'm gonna make it blue

2987.2

if it's down

2990.24

and then i come in let's see i'm not

2991.92

sure if it'll do it yeah and then i

2993.44

force a refresh and then boom i can

2995.04

change that

2995.76

you know in a matter of seconds

2998.96

quite literally and when you're dealing

3000.72

with changing requirements and things

3002.88

like that

3003.44

then i would say definitely do that so

3005.68

that you can handle

3007.2

uh it's amazing how helpful that is with

3009.2

a customer that's

3010.24

constantly changing their minds and you

3012.24

can actually can show them that almo you

3013.76

know live you can actually walk through

3015.2

and do a

3016.079

a joint session with them and say hey

3018.8

this is what it's going to look like

3020.96

and so that brings us to the last piece

3024.16

i want to talk about is the scheduler

3025.68

itself

3027.68

and so um one thing we did not do

3031.52

in the prior that we would have to do is

3034.079

pip3

3034.8

pip is the if you remember it's the

3036.24

package manager for python

3038.4

and so what we need to do is we're going

3039.839

to have to add schedule so if we do

3042.319

pip 3 install schedule pip 3 being

3045.2

python 3's version of it

3047.44

in this case it's going to say that it's

3048.8

already satisfied if you run it it'll

3051.359

install it

3052.48

if you don't it'll say that it's not

3053.839

going to be able to find the schedule

3055.44

piece

3056.4

and that allows us to do import schedule

3058.8

so i'm going to move these back up to

3060.16

the top of the

3061.28

page here to sort of get all of my

3065.119

imports together

3068.96

oh let's see and so i didn't have time

3070.96

twice oh i did have time twice

3072.88

it's already had time here and actually

3075.52

dates not being used so i'm gonna get

3076.64

rid of that so i can clear that up

3078.16

so i have to do is import schedule and

3081.119

jump to the bottom here

3084.319

and schedule works off of jobs and so

3087.44

i'm going to define and i'm just going

3088.8

to call it job

3091.76

and now instead of here you can see

3093.76

where i had my heartbeats and my check

3095.68

requests that was my this was what i had

3097.76

as my main

3099.119

so what i'm now going to do instead is

3100.96

i'm going to say that my job

3102.88

is checking those two and it's going to

3105.599

print out

3106.48

job complete just so that every time i

3109.119

run the job i'm going to see that hey

3110.64

you know i ran the the job

3113.76

now i can either do it uh it's

3117.92

doing the you know so once i've defined

3119.599

what my job is what is the function i

3121.839

want to run

3122.72

schedule says allows me to say all right

3126.4

well every time period i can either say

3129.04

every one minute

3130.24

i could say every 60 seconds i can say

3132.16

every hour every 24 hours

3134.4

all i'm going to say is do job it's much

3137.68

like

3138.16

we've probably seen if you've done like

3139.599

multi-threaded stuff in the past or

3141.28

something like that

3142.4

you define something as we do here

3145.76

and then you say run it uh what schedule

3148

does it says

3148.88

run it every time frame run that thing

3153.52

and so it's going to schedule that uh

3156.079

it's going to go in and run it

3158.48

and then all i need to do is i have this

3161.28

little loop

3162

that says that if i've got something

3164

that needs to that is

3165.359

waiting to be run then

3168.64

uh it's gonna run it and so that's what

3170.559

does what schedule does is it basically

3172.559

cues it up and then i need to do run

3175.359

pending to say run everything that's

3177.04

pending

3178.48

so i could you know conceivably

3180.96

depending on how we do it i could have

3182.24

something like i could have a couple of

3183.52

different things that run

3185.2

you know maybe one every one minute

3186.72

every two minutes another one there's

3188

every five one runs every ten hours

3190.559

and then i could basically say well but

3192.64

worst case i only want to run

3194.48

any of those every five minutes and so

3197.599

what i would do is i can say run pending

3200.16

run every job that's out there that

3201.599

needs to be run

3205.359

and then sleep here is i'm going to say

3208.48

just

3208.8

you know since i don't want to keep

3210.24

seeing if something's pending

3212.72

then i'm going to just sleep for a

3214.8

minute

3216

and come back and check it

3220.839

so that right there

3223.68

i i created my job you know my thing i'm

3226.319

going to do and then schedule itself

3227.68

it's just a couple lines of code and i'm

3229.119

off and running

3230.64

now the way this script runs is it runs

3232.4

through it says okay

3234

first time i fire up i'm just going to

3235.76

go ahead and

3237.119

run these two functions up above which

3240

is basically the job

3241.76

so i could just now actually in the main

3245.04

part of the script instead of doing it

3246.24

this way

3246.72

i could just say here i could just say

3249.92

job

3253.92

so i'm going to define it and i'm going

3255.44

to run it and then i'm going to schedule

3257.44

it and i'm going to run anything that's

3258.72

pending i can do that or i can just say

3260.64

forget that i'm not even going to run it

3263.92

um

3265.839

then i'm just going to come through here

3267.359

i'm going to define it i'm going to

3269.52

cue it up and then i'm going to run it

3271.599

and so what we'll see here and we've

3273.2

seen this actually

3274.72

as we've been running through this today

3277.599

if i

3278

run let me do this let me clear that so

3280.72

it's a little easier to see

3283.28

when i run it um

3288.319

did i miss something there date time

3291.28

time has no attribute sleep

3292.96

so oh i'm sorry because i had

3296.88

a date time time but i also had up here

3300.799

it was just called import time itself

3303.04

was the one that

3304

it's a different time where was that

3307.2

uh

3310.799

there we go import time okay so that's

3313.359

what i thought it was

3315.68

my mistake there is actually

3321.2

i needed my i needed time itself because

3323.44

you can do the

3324.48

time function from date time but

3327.68

there's also the time library which can

3329.68

sometimes be a little bit complicated

3332

but the one allows me to do sleep

3336.72

uh let's see yeah

3339.839

so now i'm gonna come in here so what

3342.559

happens when you change stuff on the fly

3344.559

so now oh it's because i need to

3349.119

uh my mistake and because i have those

3352.88

two it's going to be whichever one i

3354.16

call last is going to be the problem i

3355.68

wonder if i'm using

3356.72

the date time time at all

3360.319

i think i'm actually good so i think i

3362.16

can actually get rid of that one

3366

let's see this is why usually you don't

3369.2

want to do it on the fly but let's see

3370.64

if this will work for me

3372

there we go okay so i've cued it up and

3376.079

now it's going to wait

3377.839

and then it's going to end up waking up

3380.319

and it's going to run

3381.359

the pending job now notice this time i

3383.44

didn't run it right away

3384.96

i could have which a lot of times is

3386.96

what you're going to do is you'll just

3388

say

3388.319

you know like here i would just come in

3389.599

and say hey job

3391.52

run it and then uh here it's just going

3394.24

to do while true so i don't have

3395.68

anything that is going to end this i can

3399.44

you know i'm basically going to have to

3400.559

either kill it

3402.799

or i can actually background it and let

3405.28

it run in the background and

3406.319

periodically it's going to show me the

3408.16

updates

3408.96

and i'll flip back to this in a second

3412.88

uh but that brings us to a point here

3415.359

where you sort of wrap it up a little

3416.48

bit

3416.88

and go to q a while i go flip back over

3418.799

there let me see is it run yet

3420.24

nope i hadn't run yet so using the ping

3423.359

and the request

3424.16

classes we talked about those we uh

3427.92

the those allow us to do that ping

3431.04

or a get we looked at some of this

3434.64

dynamic application of style so we had

3436.64

the

3436.96

the classes for up or down that we could

3440.319

see

3440.64

here you know we get those different

3442.559

colors

3443.92

we looked at the scheduler itself and

3445.92

then we looked at a page

3447.28

auto refresh and so with those um

3450.319

you know that gives us our back end a

3451.68

little bit of a clean up and now we've

3453.359

got a very simple

3455.28

uh little application that we could run

3457.359

you know however we want to do it i

3458.559

guess i probably shrink this down a

3459.76

little bit even

3460.96

we could have this thing running you

3462.319

know in the background somewhere

3464

either on our you know or we could have

3465.76

this actually it could be a nice little

3466.96

thing if you wanted to do

3468.16

a page essentially on your on your site

3471.52

whatever your site happens to be

3473.44

you could hook up a couple of these

3474.64

things and have it one of those you know

3476.48

status kinds of things that you

3478.64

typically see for example i think

3482.48

maybe aws status will have it yeah

3488.88

so you could see something like you

3490.079

could build something like this

3491.119

essentially and you could

3492.24

actually you could do this and tweak it

3494.24

uh for your specific

3496

site so that you could you know for your

3497.599

look so that you could have

3499.359

instead of the ui that i provided here

3502.72

you could do something like that that's

3504.24

that that basically lists it

3507.68

so that allows you a quick and easy way

3509.92

to do that

3510.88

let's see it ran i think so we can see

3514.079

here yes so it's it ran so we've got

3516.4

this scheduled thing

3517.359

it ran through but we also can see where

3519.76

it came back around

3520.96

and it skipped a bunch of those sites

3523.119

and then it just tells us job complete

3525.68

and then it just it's going to keep

3526.88

running in the background so now we have

3528.4

our back end running in the background

3530.24

we have our whoops our whoops that's our

3532.64

foreground let me kill that off anyways

3536.48

where did that go we have our foreground

3539.2

doing its

3539.76

every 30 second fresh refresh and so now

3542.079

we don't have to touch anything

3543.2

and it's going to tell us if a site goes

3545.28

down

3547.92

and there we go so questions and

3549.76

comments

3556.16

you know what interests me so much about

3558.88

and

3559.28

first off it great presentation and also

3562

lots of thoughts that come from it but

3564.16

what interests me so much is that you

3566.319

know we have the power as developers to

3569.2

really shure up a site in a way that

3572.16

most

3572.559

canned um canned you know whizzy wigs or

3576.079

whatever

3576.559

don't usually have you know right out of

3578.4

the box um

3579.839

i'm also thinking about this gives me so

3583.2

many ideas of shoring up

3585.52

you know the distributed architecture

3587.119

with different types of techniques you

3588.88

know

3589.119

pinging different services running

3591.28

messages through

3592.559

the the pipeline to kind of then

3595.599

intercept

3596.48

you know it going out of the the top of

3598.64

the funnel type thing um

3600.4

just to confirm everything's up and

3602.079

running that's that's really cool man

3603.76

appreciate it yeah it's a it's a really

3606.559

common

3608.079

thing that's out there that i don't

3609.359

think we usually don't think about it

3611.04

too much

3612.64

uh until something breaks and then

3614.4

you're like man i could have probably

3616.4

done something

3617.839

uh and this actually i mean i ended up

3619.76

building this

3621.599

concept of an app a long time ago

3623.839

because i just had a couple of sites

3625.76

and this was back when it was a lot

3628.48

harder to have a site that stayed up

3630.319

you know it's just more common something

3631.599

would happen to break a site

3633.68

and instead of me i sort of got in a

3636.079

habit

3637.2

of every day when i'd start my day i'd

3639.599

go walk through

3640.4

my three or four little sites to see if

3642.24

they were up

3644

and make sure that my website wasn't

3645.44

down and i said well that's sort of

3647.76

ridiculous and so what i did is i just

3650.72

you know built a little app that did it

3652.4

and you can do you could actually expand

3654.64

from this really easily

3656.559

and quickly you could do something like

3658.16

if the site goes down

3660.079

um you know if i do a check and the

3662.16

site's failed then i also send an email

3664.319

out that says hey your site's down

3666.079

you know i thought about adding that

3667.2

into this but it got it would have

3669.04

gotten a lot longer

3670.079

and you know we could have gotten a lot

3671.28

more complicated and i wanted to keep

3672.88

this a simple app

3674.24

but i think you can already see it

3676.4

there's a lot of things that you can do

3678.4

even with this to just have a you know a

3682.16

quick way to monitor what's up what's

3684.079

down

3684.88

and like i said it'd be really easy to

3686.72

add some notifications on top of it as

3688.64

well

3689.04

and it's it's just to me it's a good

3690.72

example of where

3692.16

within you know probably i don't know

3695.28

overall maybe an hour or two

3697.04

and you can have a full featured

3698.559

application using python and django that

3700.72

that has all of these pieces and you

3703.28

know you're ready to go so it's not and

3704.799

it's not even a

3706

like a prototype necessarily or

3708.079

something like that i mean it's a

3709.2

you've got a full app that you can run

3711.119

quickly you got a database behind it

3712.72

you've got tools to administer the data

3715.2

you know everything you possibly need so

3717.92

good

3719.2

other questions and comments this is

3722.4

really good

3723.119

rob i i like the quick and ease and the

3726.72

administration side of it because

3729.039

with the polling in that i could

3730.72

potentially write use this

3732.72

built the front end for my test

3734.24

generator tool so that you can build

3736.64

the test cases and actually run them

3738.4

from the gui instead of having to

3740

actually

3740.72

write the script yeah

3744.079

yeah well and actually um

3748.079

i think i don't i don't know if you know

3750.559

if you've seen this but that's

3751.92

actually

3754.96

one of the nice things and i may show

3757.76

this at some point because we did look

3759.52

at we did a little bit with python

3763.2

testing

3765.52

but it also with selenium which you've

3768.24

talked about

3769.2

uh it does allow us it has a python test

3773.92

uh export as well

3777.039

uh https developer oops i need one there

3781.28

there we go um

3784.559

that i can do let me just kick on it

3786.64

click on a couple of things real quick

3790.559

oh i'm not recording or am i yes i am

3792.64

recording so i can take you know i think

3794.079

this

3794.799

probably enough you've seen this before

3796.96

is i can take the normal

3798.559

stuff i do with selenium and it does

3800.4

have

3801.599

an export to python's pi test

3805.599

which is insanely i don't see that's in

3810.4

downloads i'll just show that real quick

3812.48

because i've actually been playing

3813.44

around with this lately

3814.72

for uh some scraping type stuff i did

3818.16

that made it so insanely easy

3822.559

using selenium stuff as you can see that

3825.039

it's actually

3827.119

you know it generates a real simple

3830.4

uh python script depending on how you do

3832.319

it and it uses the same stuff that

3833.68

you've seen

3834.72

i know that michael's talked about it

3836.079

you know extensively as far as the web

3837.599

drivers that are out there once you've

3838.799

got it

3839.76

uh python is a tool that has built up

3841.52

real has built a nice framework to work

3843.599

with that it's one of those just like

3844.96

java and c-sharp

3846.799

that you could do something

3849.839

much more complicated is i could

3851.359

actually use this i mean this is from

3853.28

scratch but i could

3856.16

and uses the pi test stuff but i could

3858.16

actually basically steal

3860.72

this code build a web driver and i could

3863.44

actually use that

3864.64

as part of my monitoring is i could get

3866.319

something you know pretty complicated

3868.96

um i can also like you said i mean i

3871.2

could i could build something that runs

3874

my test scripts and then reports it back

3876.4

somewhere and then just ping that you

3877.92

know periodically to see if the tests

3880

failed um or i could even return it yeah

3882.4

i can and i could add to it there's some

3883.76

other things i could do right now we

3885.119

just do pass or fail

3886.72

i could uh within this i could actually

3888.88

grab the value that's returned

3891.44

uh in these you know like in this case

3895.92

where i'm looking at what the value is

3898.559

this return

3900.72

oh let me save that save that off

3905.599

and i could actually do something to

3907.28

display that so i could actually have

3908.799

that

3910.319

display here you know maybe like last

3912.079

return value or something like that so

3913.599

you can

3914.319

you can do a lot quickly uh like i said

3916.559

and it does have it's

3918.079

that's why i like to this is an

3919.2

application as an example is it just

3920.72

gives you a nice starting point

3922

point where there's a lot of things that

3923.599

you could you can you know

3925.119

leap from this platform to

3929.52

excellent other questions and comments

3936.4

all right hearing none that brings us to

3939.44

the end yet again

3940.48

so as always appreciate the time the

3942.16

feedback the interaction

3944.079

um you know all of the the time that you

3946.4

spent i know that we we spend it

3948.319

you know it is self-focused and extent

3950.4

because we want to

3951.359

make ourselves better and our career

3952.72

better but it is uh

3954.64

all that time spent is also great as far

3957.52

as the group is concerned we get some

3959.28

you know having the comments and the

3960.48

discussions it helps all of us

3962.4

grow if you have any questions about

3964.319

this or any additional information

3966.4

as always email info developingware.com

3969.28

is out there

3970.16

we have the contact us form on

3971.88

developmentor.com

3973.44

we've got our youtube channel the

3975.28

easiest way to go out there is just

3976.48

youtube and just do if you do

3977.76

developpreneur it will get you to the

3979.599

developer nor

3980.88

uh channel we got a lot of stuff out

3982.64

there we've got literally

3984.24

i think we're up to like 200 videos or

3985.92

something like that right now and it's

3987.2

just like it's growing by leaps and

3988.88

bounds we're definitely over a hundred

3991.359

um and then the vimeo we still update

3995.039

that

3995.68

somewhat regularly most this the new

3997.359

stuff the most part is going to youtube

3999.039

but

3999.44

these classes uh the mentor sessions

4002.64

still show up on develop

4003.92

the developer nor channel on vimeo as

4006

well and then we'll eventually end up on

4008.319

youtube

4009.68

and of course we've got the building

4010.64

better developers podcast uh the easiest

4013.119

way to get to that is

4014.16

you know you can do your favorite

4015.44

podcatcher whatever it happens to be

4017.599

or if you've got alexa you can just say

4019.76

alexa enable building better developers

4021.599

and boom it will go out there and grab

4023.28

it for you get the latest

4024.96

uh episode of that as always our goal is

4028.559

making every developer better

4030.4

we appreciate the time you spend doing

4032.16

that and

4033.68

go out there and have yourself a great

4038.87

[Music]

4046.839

day

4051.87

[Music]

4055.359

you