um anybody in the Raleigh area so I'll
be going to All Things open uh actually
tomorrow tomorrow I'm going to Raleigh I
get there Sunday I'll be at this
conference called All Things open so
Sunday Monday and Tuesday looks to be a
gay old time in the non-homosexual way
of being gay um looks to be good starts
at like 8 or 9 in the morning goes till
7:00 at night they've got socializing
they've got classes they got kinds of
stuff going on so I'm going to go there
so I can smooze so I can smooze with
tech people and either create a pipeline
to Asheville or a Lifeline to get the
hell out of Asheville if everything kind
of Goes to
Hell which is where my bed is I mean if
I'm gonna if I'm gonna have to say where
my bed is I think it's gonna get bad for
Asheville think it's gonna get bad for
ash don't worry everybody I Asheville is
gonna be like New Orleans after Katrina
New Orleans came
back well yeah if you ignore the 110,000
black people who left New Orleans New
Orleans came back that's what I love
that's what I love about the modern
world if you ignore the people that you
didn't want to see anyway and just focus
on the people that you want to see then
yeah everything's
great hey look hey look well off white
people are doing better in in in New
Orleans
obviously it went
well
any
206 all right well guess we'll start the
class I guess I'll start Meandering uh
to get to the class uh just so you know
if I seem a little bit hairbrained uh
nowadays uh we did have a Biblical flood
here in Asheville North Carolina and
although I question the terminology
biblical let's just say it it was a hell
of a flood basically uh this portion of
Western North Carolina more or less got
destroyed we still don't have water it's
been four weeks after the hurricane and
literally I have to bucket bathe with
lukewarm mud water after my runs in the
morning there is nothing like getting
done with a nice refreshing run in the
morning and then going into your bathtub
with a little pot of lukewarm water and
sponging yourself off uh that's what
we're currently dealing with when will
we get normal water who knows who knows
they gave up even trying to tell us when
that was going to happen so anyways if I
seem a little hectic all that kind of
stuff uh again dealing with a lot of
what
happens when you're little chunk of
society goes through a Biblical flood
but anyways I'm here trying to do do
this stuff and do these types of classes
again anybody that's new here these are
all beta classes basically with silic
cond Dojo the idea is it's not just the
class
itself but it's the uh that I'm teaching
you but it's also the material for the
classes how all this stuff is done uh so
that this can be replicated by other
people basically everything that I'm
doing here is essentially open for you
folks to use you can take all the
material that's sitting there on GitHub
um and you can use it as you see even
commercially right you could go to New
York York City New York City and run a
class for $100,000 using my material and
God bless you if you get people to show
up I right I have no copyright there so
that's what's going on um one of the
things again for material and all that
if you need additional material these uh
videos or these classes are being
recorded in a camera that's right over
here in 4k those do go up to the YouTube
channel the Eli the computer guy YouTube
channel and are generally up either the
same day or the day after I do these
classes one of the nice things with the
4K is so zoom zoom uses a
1080p uh codec res um encoding codec um
that's pretty
crappy like it's 1080p but it's pretty
garbage uh so one of the things that
I'll tell you is if you want to watch
material later if you go and you watch
the 4K version of these classes um you
can actually see things like in 4k in 4k
you can literally read these tabs uh if
you zoom in we're on Zoom that's just
not going to happen um again everything
here is on GitHub Sil cond Dojo um
GitHub Sil cond Dojo online classes and
if you want to connect with me connect
with my LinkedIn profile uh that exists
so you know there's stuff that's going
on uh inperson classes are coming back
so even before the flood I decided I
didn't want to do inperson classes uh
they will be coming back to Ashville uh
some classes will most likely be in um
November and then one of the things I'm
trying to do is also do inperson classes
in Raleigh again try to create a
pipeline between Asheville and Raleigh
um and those will be coming God knows
when uh we do have the additional Meetup
uh for if you are in the Asheville area
or can become part of the Asheville area
solo cond
Dojo hyphen Asheville Edition that is
there uh donor box again these are free
to the end user classes it doesn't mean
that they're free crap costs money me
going to All Things open cost money so
if you find Value in these classes if
you find Value in these classes and you
have a couple of dollars in your pocket
there's a donor box link I don't know
somewhere around here I do got to get
better with advertising that but anyways
there's a donor box link somewhere click
on that throw in how much you think this
class is worth and it'll keep these damn
things going uh and finally uh if you
have a question make sure to raise your
hand in Zoom CU I cannot see it if you
don't uh Zoom raise your hand right
because again some people go like and I
can't see that and then finally again if
I didn't say it this time again I will
be at all things open in Raleigh that's
a conference in Raleigh um be there uh
get there tomorrow night and I'll be
there uh through Tuesday uh so if you're
going through
um looks like you're done talking the
oh Zoom zoom's screwing with me
anyways if you're in the Raleigh area if
you're going to All Things open I will
be there if you're on the Raleigh area
you might take a look at that conference
it actually looks pretty good um so
that so with that are you ready I don't
know if I'm ready oh my
god oh there is nothing like a Biblical
disaster just to screw with your brain
but anyways you guys got to push the
ball forward you got to push the ball
forward it's okay to cry for all the
people out there I just want you to know
it's okay for a man to cry it's okay for
a man to go into a corner and dry heave
um after the work is done after the work
is done you can ball your eyes out as
you're driving to the dump to throw
everything into the dump important thing
is you keep
working any so we're going to be talking
about bottle uh today and actually uh
this class is going to be relevant uh
for most of the web app Frameworks um
with uh oh with python um again one of
the the the problems that we run into in
the modern world of technology is there
are so many ways to skin a cat again
back when I got into technology or it
specifically back in about 2000 uh you
had three options right you got your
mcse you got your novel certification or
you got your Cisco certification and
that was it right whether whether you
work for the military or whether you
work for a hospital or whether you work
for an education system or real real
estate company or whatever else they all
used that same technology uh it was
really easy it was really easy which one
do you want to learn one of the big
problems we get into in the modern world
is there's just a thousand options there
are a thousand options to do any damn
thing hey you want to put up an about me
web page there's 50 ways to do it right
back in the day it used to be IIs or
Apache done now there's a gazillion ways
to do things anyways so when you're
dealing with python so python is a
programming language that we use we use
it here it's our default standard
because it does a lot of cool stuff that
I care about with python you're able to
create web applications when you think
about a web application basically all a
web application is is a web page with
some fun functionality attached right so
you can create just a basic web page so
um with uh oh with this this is a web
page and this is active and this is live
and this is on the internet if you go to
64 two.
22514 d84 you too can see this amazing
web
application anyways again we talk about
web
applications you know you start here and
build up any so when you're dealing with
python basically the web app framework
is what allows you to turn python code
uh into a web application now there are
a lot of different web app Frameworks
out there there's ajango there's flask
there's fast API there's bottle there's
pyramid is Pyramid a anyways I don't
know there's a whole crap ton of them
out there I really do like Jango I
actually really like d Jango but damn D
Jango is
complicated oh there is so much to
Django we are going to do D Jango
classes just as soon as I can get my
brain arounded enough to teach you I
could deploy something in D Jango that
doesn't mean I can teach it to you right
that's that's the issue that would run
into so anyways basically when you're
going to be creating a web app with
python you're going to use a web app
framework uh and we use bottle because
it is dirt simple doesn't really come
with anything so again D Jango is
basically a kitchen sink type thing uh
when you use it it comes with a database
it comes with a web server it comes with
something called om comes with a whole
bunch of stuff in that package which
makes it really powerful but also has
pretty steeply learning curve uh what I
like about bottle is it comes with
nothing damn near nothing uh but it
means that the learning curve is pretty
damn simple again B Bas basically Bop
right that that that is an actual again
web app it's a web app that says hello
world but you can just do that and go
with it uh but then one of the things to
understand um with this is that any of
these web app Frameworks are basically
going to use the same process more or
less for deploying them into the real
world right so you can run you can run
uh these scripts on your local computer
and you can interact with them as a web
app and get all the functionality but if
you're actually going to deploy them uh
up onto the internet or even into your
internal environment for people to use
them right more people than you to use
it uh you're going to have to go through
a number of steps and so what I'm
showing you today the same same but
maybe slightly different uh with
whatever it is that you're going to be
doing it's basically going to be the
same process so if you use Django or
flask or whatever else
more or less use chat upt do some
searching but it should also all
basically uh be the same we take a look
at the code uh that we're basically
going to be using today uh this is what
the code is going to look like so again
I'm now doing these in MD files uh MD
files are called markdown files they're
supposed to be the open way of doing
documentation oh don't know again this
is all beta I'm doing a test so if
you're like what is this this is a
markdown file we'll see how it goes uh
basically with the code that we're going
to be looking at today this is a very
very very basic web app so if you've
been running bottle up until this point
in time you should basically understand
what's going on so from bottle so from
the bottle module you're going to import
route run uh and default app now there's
a little bit of difference here right so
again if you're going to be running
something on your local computer it's
going to be different than if you're
actually going to put into a production
environment so at rout for the root so
basically if somebody just plugs in
127.0.0.1 or whatever your domain name
or whatever else is
what are they going to get we're going
to get a return of Simply hello world so
for this it just simply says hello world
and it literally prints out on the
screen hello world that's it no HTML no
fancy just hello world then we're
going to come down here and these lines
of code are going to be different uh so
if you've been learning bottle up until
this point these are slightly different
so if name equals main do this so this
is an important thing this is an
important thing if you screw this one up
it can be painful so basically you're
going to be using something called
gunicorn we talk about this in a second
we're going to be using gunicorn to run
this script so normally we run this
script and we just run this script so we
hit the go button or do Python 3 and run
the script and we do the script right
now what we're going to be doing is
we're going to be using gunicorn
gunicorn is a python web server that's
actually for production we're going to
be using gunicorn to run the script but
the problem is is when gunicorn runs a
script if run is over here where we
normally put it gunicorn is going to try
to run the script and when gunicorn runs
a script the script itself is then going
to try to run and you get some really
weird really weird error logs you just
get those looping garbage of an error
log right because gunicorn is trying to
run the script but by trying to run the
script it then runs a script within the
script that it's trying to run and it
kind of sort of that does function sort
of you're just going to get a whole
bunch of Errors so anyways what this
says is is if name so basically name is
a builtin variable name for python so
what it's going to say is if name is
Main and so what main is basically this
says that you are running the script on
its own you have called The Script on
its own so I put in Python 3 script name
the name is me I hit the Run button up
there the name is main I use gunicorn to
trigger it name is not main cuz calling
this script from outside so is the
script running on its own or is the
script being called from outside if it's
running on its own host equals 0.0.0.0
so basically run off of any uh IP
address that's on the computer 127.0.0.1
whatever the actual IP address is so on
and so forth and do it at port 8080
right if you're running it from
somewhere else again from gunicorn it's
an if statement so you're just not going
to do that then down here we have my app
equals default app so this is going to
be a new function that we're using and
this basically gives us an app name uh
so when you use what's going to be
called
wsgi Web servers so again that's what uh
gunicorn is it's a wsgi web server and
one of the things you have to feed it is
you have to feed it the script name and
then you have to feed it the app name
and so this is where we get the app name
from so basically we package all this up
as this particular app name so that when
we call this we're going to use script
Name colon app name and that is what is
going to fire this off so this is going
to be some new stuff that you have not
seen before and again if you do not put
that in there you're going to get some
uh interesting interesting things uh
when you want to run a strip script with
gunicorn so gunicorn is its own external
web server again something called a wsgi
web server again you can run the script
so from where you're at right so
basically oh from where you're at
you you go into the command line you go
to the folder wherever your script is
and then what you can do is you can run
the command gunicorn and you're going to
give it workers right so what workers is
and why we're going to be using gunicorn
is gunicorn is called a
multi-threaded web server so when you
use the web server that's built into
python so when you're using bottle or
Django or anything else and you're using
the built-in web server one of the
problems with it is that it's single
threaded basically it can only do one
thing at a time again if was just you
and you're doing some ping commands or
whatever the hell else who the hell
cares it's not going to matter right run
the action wait for the action to end
send back the response run the action
right back and forth right once you
start doing with lots of people though
once you start using dealing with
multiple people you want a
multi-threaded environment what a
multi-threaded environment is is
basically where it can do multiple
things at once so one user is trying to
do something and another user trying to
do something and another user is trying
to do something and another user is
trying to do something and four people
can basically be doing something at the
same time and then it's able to rotate
through the process and so that's what
you get with gunicorn and something
called workers so you do a hyphen hyen
workers and then you tell it how many
workers you want Bas basically how many
threads that you want the standard
default is
four you can go and you can do a Google
Search and you can research how many
workers you should have it's up to you
look at your own performance reports
basically if you have too few workers um
and you have too many users coming to
your site everything's going to get
backed up because there's not enough
open processes for them to be able to
use apparently if you use way too many
workers basically each one of those
workers use Hardware resources in order
to do what they're doing and so then
your computer will slow down because all
the resources are being used for these
workers whether or not they're actually
functioning and so basically there's
this whole thing about how many workers
you're supposed to use and again for
your production
environment figure it the hell out again
if you're dealing with a uh you know a
decent little website if you're dealing
with an internal app that type of thing
the default standard seems to be for
workers so start with that you then do
hyphen hyen bind so this is what you're
going to be binding to and this is the
IP address that you're going to be
binding to just like to run up there so
basically what is gunicorn going to
respond off of will respond 127.0.0.1
will respond to a particular IP address
that has been configured for the
computer that whole thing if you do a
0.0.0 basically it means it's just going
to respond to any IP address that's
configured for the computer and you're
going to do it at Port
8,000 now this is going to be in the
same folder as that script so the script
is my
app.py my app.py so you're going to say
my
app.py and then actually right there
should be my
app anyways and then the name here so my
app.py we remove the py and then we have
the app name so script name app name
don't put the py in there and that's how
this is triggered so basically we go to
a command
line that's the wrong command line got
so many command lines as this we got the
command line right so we got LS L uh and
we can see here got my my app.py here uh
basically I can have the command I
always already put in before gunicorn
hyphen hyen workers for hyeny bind 0.0.0
colon 8000 my app my my app so it's my
app is the script name and my app is the
app name those can be different um
basically I run that when I run that I'm
now going to be getting this kind of
thing and again if you if you if you
don't deal with that run thing properly
you're going to get some weird stuff
coming up here but anyways I can now go
over to my page
127.0.0.1 colon
a000 and I can say hello
world hello world and then hyphen hyphen
75 now this is one thing that you might
want to think about putting into your
scripts especially when you're testing
stuff is I've talked about this before
the issue with caching mechanisms
caching is
awesome until it's not right so what a
caching mechanism is is basically where
your system or some system down the line
makes a request gets the response back
and then saves that response for later
so instead of going and doing the whole
Loop in the future you can just go to
the cache so one of the things
especially when you're testing making
sure your web app actually works is by
putting in some kind of dynamic
information on the page you verify that
it's actually updating properly that
didn't it didn't provide you a response
once
and now you've just been getting a cash
for the past hundred times and like the
server is like you know having a brain
farm so basically this is just a random
number here so if I do refresh refresh
refresh refresh refresh I don't I do not
care what that number is all I care is
every time I hit the refresh button I'm
getting a different answer that's giving
me a dynamic response just so I can make
sure that that's working basically all
that is is putting a Rand INT in there
so I do a number so number equals Rand
in you know between zero to 100 and then
I do an F string saying hello world with
that number and that's what gives me
that refresh there so this is all there
is as far as gunicorn is
concerned where the hell am I at I'm
getting lost I'm getting so lost I'm so
lost okay does anybody have any
questions up until this
point any hands
No Hands okay now let's talk about the
tech stack um so again this is one of
the big things um whenever you're
building stuff is that is a stack again
remember in the technology world this is
all this is all easy this is all
easy don't let the real Tech
professionals hear me say that as I say
as I say new people everything here is
easy dcpip is easy Linux is easy um
python is pretty easy bottle's easy go
corns
easy take all those easy things and put
them into a stack and that's when
everything goes down H so it's important
to understand how the stack works so you
can start trying to figure out the
simple things that you're supposed to
understand in order to make the stack
work all right so the first thing is
going to be DNS right so you're going to
have like my app so my
app.com so bu somebody goes to their
computer and they click in my
app.com what happens next basically so
what's going to happen is there
something going to that's that's what's
going to happen something called DNS DNS
domain name Services what this does is
it resolves a domain name to an IP
address so
20866
55.4 this is what the computers actually
care about the thing is we're
humans we're not going to remember that
and so that's why we come up with a
human readable name the first thing is
you do do DNS and it's going to resolve
to this this is where you go to GoDaddy
Cloud flare whatever you buy a domain
name for10 or $50 a year or whatever it
is now and basically what you're going
to put into that DNS setting is you're
going to put in whatever the domain name
is and then the server that you're going
to be going to now with this again
especially since you're building your
own web app you can point this to
basically any IP address uh that you own
or that you
control uh so like with me we've got um
I've got this thing running on Ubuntu or
digital ocean right now and so basically
uh for $6 a month um I'm using a droplet
over a digital ocean and they gave give
me an IP address of
64225 one4 184 so I wanted if I could
buy my app anyways whatever domain name
I could buy basically I would point it
to that IP address so when somebody goes
from there it will then go to to my
server once that happens right basically
you're going to get routed to a box
somewhere and again this box could be an
instance again a virtual private server
it could be a physical box that's
sitting uh in your server room somehow
basically the traffic is going to have
to get to that box and that's where
again we talk about the Tex stack if you
have this running locally you might have
to do things like port forwarding on
your on your router that's a class for
another day basically though what needs
to happen is people have to be able to
come to your server at the particular uh
Port so what we really want at the end
of the day is Port 80 so we talked about
TCP ports before transmission control
protocol ports within TCP IP uh you have
IP addresses then beyond the IP address
you have a port and that Port is used
for what protocol you're using 20 Port
22 is for ss6 Port 443 is for SSL
importantly for us 4 80 is for HTTP when
you go to a website such as
CNN.com the default is Port 80 and so
you don't have to put it in you simply
put in CNN.com and you get dropped onto
their web page if you want to go to a
web page at a different port then you
have to do whatever that Port is so
colon let's say 8,000 and again that's
where if we take a
look oh at my uh at my thing here uh if
you can see it 1 127.0.0.1
colon 8000 the reason that I have to do
that is because gunicorn is providing
this particular web page at 8000 but
that's ugly that's a pain in the ass I
don't want to deal with Port 8000 I want
to deal with Port 80 so basically what's
going to happen is you're going to be
sent to your computer when you hit your
computer you were then going to have
your OS you're going to have your
operating system it's G to be lenux it's
got to be auntu Arch mint Red Hat fedora
OS whatever else or God app help you
it's going to be
Windows hopefully it's not Windows
anyways you are going to have to
understand how that operating system
works especially from a server
perspective the main thing that you're
going to be looking for here is that you
understand how security works on that
particular operating system so in the
Linux World we're going to be using CH H
WN so for change owner uh or to change
permissions but basically you have to
you really have to understand how the
permission structure work works on the
damn server again class on its own when
on OS you're then going to be installing
something called
engine X engine X is a web server so
basically if you want to host CNN.com or
whatever web page onto your server you
could use engine X you you will have
heard of Apache again there's engine X
in the windows World there was IIs I
don't know if it still exists anymore uh
basically these are web servers normally
what happens in the web server is you
have a folder and that folder is
something like
index.html and you come to engine X and
it will provide you with whatever the
hell is on index HTML but what we're
doing now is we're not actually using
enginex simply as a web server we're
using it as a reverse proxy server so
what a reverse proxy server does is when
somebody comes to my app.com goes to the
IP address comes to the server comes to
engine X basically engine X is then
going to out where the traffic should go
oh you're looking for my
app.com where is that going to go and
the cool thing with this is it can be on
your box so that's what we have running
here it's actually on the box or it
could be on an entirely different box
that's when something called the the
power of the reverse proxy server there
a whole bunch of configurations and
things that you can do there but you
could actually have multiple multiple uh
web Frameworks that are running they can
be doing synchronization and things and
then engine X can literally Route
traffic um based off of current
conditions that type of thing it's
called reverse proxy Ser but today we
are not going into that mess we are just
going to Simply keep it on our server
and so from here this is where we're
going to go to
gunicorn so gunicorn is the python web
server and basically presents python
webs as web apps and so engine X when
you come to this is g to go and it's
going to go to gunicorn now one of the
things with unicorn is that it actually
has to be running again remember with
all this kind of stuff nothing happens
magically nothing happens magically at
all you have to configure it so one of
the things you have to make sure is that
you actually turn kunicorn into a
service and we'll go into that a little
bit later and basically Al it means when
you turn it into a service and you
enable it is that it starts when the
server starts running so you turn the
server on and gunicorn is up and engine
X is up and so everything gets routed to
gunicorn if you don't turn gunicorn into
a service you either have to manually
start it which you don't want to do or
the communication will simply fail out
because it doesn't exist because you're
forwarding it down basically when
gunicorn runs as a service basically
it's going to be triggering your bottle
app that you created to my little hello
world right when gunicorn starts as I
showed you it is going to be starting
that particular app and that particular
app is going to be written in Python so
again a relatively very simple very
simple thing that we've created and this
is what the tech stack looks like all
these things are dirt simple tying them
all together is what turns into a
colossal pan
ass uh let's see here uh prerequisites
uh for when you're going to be setting
all of this up uh so one of the things
you need to be thinking about uh is
security again we just did a cyber
security class for programmers one of
the things you need to be thinking about
is security and basically one of the
things you have to understand is that
your system you know hackers are going
to come after it hackers are going to
try to attack your system so one of the
things that you want to do is you want
to decrease the plane of um
vulnerability basically how how how easy
it is to attack your system so when you
run gunicorn when you run gunicorn which
is basically running your web app what
are you not going to do ever ever ever
you are never going to run this as
root because if somebody can compromise
your web app they then have the
Privileges of root on your entire server
and everything is going to go to hell so
one of the things the first things you
may want to do is you may want to create
a user such as www right so there's some
reserved users www hyphen data other
users basically try to plug it in it's
already being used find something else I
would argue for services like this you
just find a name that you like that's a
nice good service Serv name that you're
going to remember we're going to go
through this there's going to be a lot
of configurations there's going to be a
lot of to
remember make it simple make it simple
and do it on every damn box that you use
anyways so one of the first things you
may want to do is pseudo ad user and
whatever you want your web user to be
right and so that web User it's going to
be its own individual User it's only
purpose only purpose in all the world is
to basically run gunicorn so one of the
nice Parts with it is you can lock it
down so it can only do whatever gunicorn
is supposed to do or you can give
specific rights to it so again it can
only do what the hell it's supposed to
do and nothing else past that we're
going to go into it uh pseudo apt
install engine x uh so basically if
you're sitting down at a Linux box so
with this we're going to assume you're
at a Linux box you're using Digi lotion
or something like that if you're using
another system God help you that is one
thing that I'm going to tell you again
people ask like what computer you should
get if you want to learn programming
honestly Linux Linux is really good
Ubuntu is great uh the main thing with
with Linux is that you can actually run
a lot of stuff on your system really
really really easily uh beyond that Mac
many of us use Mac and then you know
there's the porch clubs you got to use
Windows one of the things you need to be
thinking about with this is again how
you're actually going to be in
installing and configuring things that's
one of the re that's one of the things
like with Windows uh so about a year or
so ago um I was going to start doing
more stuff with windows with python and
one of the issues with things like
device drivers and configurations it was
just a mess just a mess so anyways uh
Ubuntu is really nice uh pseudo app
install engine X so basically this is
how you install the web server onto your
system you hit yes you install it now
from wherever you're at
you're going to need to make a directory
for your app right whatever the app is
app name is you're going to make a
directory for it so if you're in the the
the the home home folder for the WW user
www user you would then do uh make
directory
mkd my app and that will create a folder
there right uh then you're going to
change directory to go in there uh this
can be done either before or else after
pseudo app install Python 3 hyphen venv
so I actually haven't done a class on
venv yet at least with siloc cond doo
there is a class on YouTube about it
this is for virtual environments
basically this is going to be very
important uh for packaging apps to go
somewhere else right so if you're just
create an app for your own little
computer it doesn't matter uh one of the
issues that you're going to run into
though especially if you're uh creating
apps they're going to be shipping off to
somewhere else is is is making sure you
actually document things like all the
modules that you use use right so if I
install a package for this project over
here and I'm creating this project over
here and I'm writing it all out and then
I forget that that I I I already
installed the module previously and now
I'm using it here one of the issues you
can run into is you can kind of get
confused about what modules your package
actually or your your app actually needs
so what a VV does what the virtual
environment does uh is it allows you to
install uh all of the modules into one
environment uh for your app so when this
app runs it only uses the modules that
you've installed for that particular
environment when this app runs it'll
it'll use the uh the modules that have
installed for any different environment
the nice part with this too is that it
all saves that is basically in a file
and folder structure so you can copy and
paste this whole mess and you don't have
to go into a big reg roll so we going be
using a virtual environment the other
thing too is that I'll tell you is when
you go to deploy to digital otion or
whatever else there is a lot of
documentation out there there's a lot of
great documentation out there that Al
all defaults to you using a v andv a
virtual
environment you can make things run
without a virtual environment they don't
necessarily give you the documentation
for how to do that though so again one
of the things you're going to learn in
the technology world again this whole
idea of best the best way to do stuff I
want to tell you I do a lot of things
because it's been freaking doc dou
umented where what what can I use that
has support and I'm going to use that so
virtual environments once you've
installed virtual environment from the
directory that you're in you're going to
do Python 3 hyphen M venv and then
whatever the V andv name is so this is
going to create a folder with a
structure underneath for that virtual
environment now for me I normally call
my v and vs V and V because it makes
life easier because again you got to
remember this for when you put it into
configurations if every single V andv
that you make has a different
name have fun with that I just call it
be andv uh
source so basically uh once youve
created that virtual environment uh
you're going to do what's called Source
the virtual environment name so V andv
bin activate and this is going to
activate your virtual environment uh
let's go back
here um
contrl
C uh is it exit
yeah
ah give me another give me another tab
uh tab with
Pro okay so basically I'm here just so
you understand how this virtual
environment Works LS iph L okay so uh
I'm in the www directory here uh I have
my my app.py here and I have this
virtual environment here right if I see
D and V and
V oh and do LS basically you start to
see that there's a there's a folder
structure under there don't really worry
about it too much right now so what
we're going to do is we're going to do
Source um Source venv because that's the
name of the virtual environment
bin slash activate and so one of the big
things again whenever you're using
computers command line let's always take
a look at what this prompt looks like
this this this is going to matter a lot
so right now this is what my prompt
looks like and now
this you see I have ve andv here
basically what this now means is that
I'm running in this virtual environment
so if I try to run the script previously
when I'm outside the virtual environment
the uh the packages the modules are not
installed so it should fail again this
computer I'm not sure because a whole
bunch of crap on it uh but basically now
that I'm in the virtual environment I
can then run my script if I do something
like a pip
list uh basically this is going to tell
me uh the modules that are installed
into this particular uh virtual
environment so bottle gunicorn pip right
so those are those are basically the
modules that we're going to be using
today and so this is what you want in
your be
andv okay uh so again uh for this again
we're going to have to install bottle so
Python 3 hyphen M pip install bottle
Python 3 three hyph M pip install
gunicorn bottle is for the uh you know
the web app framework gunicorn is for
the web server now you can install
gunicorn onto your computer all right
there's like a you know apt app pseudo
apt install gunicorn or's some command
in order to do that uh basically by
installing it just within as a pip
package though it kind of keeps it
contained a little bit more so hopefully
you don't have security issues security
leaks that type of deal so you do it
this way gunicorn will only be uh usable
from within that virtual environment uh
if you do it for systemwide then it's
available for the entire system whether
that matters to you who the hell knows
okay so let's see
here
uh so this is the script so my my hyphen
app.py and again this is the hello world
this is the if name equals main this is
what we're going to run uh then we're
going to create
the app name um let's see here then
we're going to create a
service so the service is going to be is
this is what's going to start up uh when
the computer starts
jock jock comes jock go how many jocks
are there how many jocks are there in
the world two jcks apparently anyways so
basically again we're looking at a stack
okay so we got python Python's done
we've got the virtual environment all
that kind of stuff uh bottle app we
created the hello world bottle app and
so now we got to get to that gunicorn uh
component again we got to get to that
service component and so basically what
this is going to be do it's going to do
sudo Nano so uh whenever you're using
Linux at the command line you have to
find some kind of text editor here's a
whole bunch of them my go there's so
many text editors and I'm just going to
let you argue about which text editor
you want to use if you want to use emac
you go girl if you want to use Vim or V
or whatever else fine I like Nano Nano
is just dirt damn simple anyways you say
pseudo Nano EGC system MD system app
name whatever the name is that you want
to be do service right so basically what
this is doing is this is creating a
service uh for for your app or for your
for gunicorn basically when the computer
starts this is a service that will start
up for you now there's two ways in order
to create the service you can either
create the service with an IP address so
127.0.0.1
call a000 or is a
socket um so
basically how do we put this get rid of
this for a
second so there's two ways to do the
service so engine X engine X is going to
have to connect to the service somehow
but hooker by croak it's going to have
to get there right so basically you have
gunicorn you're creating the service and
there's two ways in order to do it
right basically one way is to run
gunicorn locally at
127.0.0.1
uh colon whatever HTTP Port you want to
use right so engine X when somebody
comes in engine X will simply redirect
to this that's running because it's a
service and life is pretty easy right
the good part about using the IP address
here is you don't have a lot of security
issues you don't have a lot of privilege
issues you don't have a security issu
isues you don't have a lot of
troubleshooting problems you just set
gunicorn up to run for 1 127.0.0.1 or
whatever else and you wash your hands
with it um
theoretically theoretically there can be
some security issues there because
basically what's happening is if
somebody can get to that IP address if
you misconfigure how that IP address is
let's say 0.0.0 or you do something else
theoretically somebody else could get in
and basically instead of going to engine
X they could bypass engine X
to get there to where gunicorn is
actually delivering the web app and
theoretically they might be able to do
something what are they going to do I'm
not really quite sure but theoretically
they could do something so that is
considered not necessarily the most
secure way it's the most scalable way uh
basically because engine X can point to
to different servers or such maybe not
the most secure so one of the things you
can do is a
socket so basically and we'll go over
the configurations in a bit what happens
is when gunicorn Boots up yeah actually
creates a file so my app
Dock and so this do sock is not really
accessible from the outside world
regardless and so engine X when people
come in it gets pointed to this do sock
file the issue with that is you have to
understand how Linux permissions and
Privileges and all that kind of crap
works because because gunicorn is going
to have to have permissions to actually
be able to create this particular
particular file and Eng X is going to
have the proper permissions to actually
be able to access that particular file
and ever order for everything to work
properly uh if any of these
configurations are wrong it makes you
sad and you want to cry uh so again if
you're starting out I would say do the
127.0.0.1 basically do the network
configuration it will make life easier
uh
jock which jock is it jock what's up
uh thanks I switch from my phone to my
computer so I'm still trying to W my
head around you explained it a couple
times but what exactly guda corn is is
it a is a service that serves on your
server or it's not a bottle it's not a
framework like bottle so I'm still
trying to figure out what exactly is
gunicorn per se and it just help the
server be able to find the the website's
easier or the IP address so that's why
I'm trying to wrap my hand around like
what exactly unicorn is I don't know if
I'm making myself clear yeah so gona
corn is something called a
wsgi web server so basically
so again when you when you initially
install python there's actually a
default web server that's built in
that's really crappy so you can actually
just write python code and present it to
to an IP address and use it as a web
service or something um basically what
gunicorn is is professional sat down to
harden it make sure it's multi-threaded
do a whole bunch of this kind of thing
uh and basically so what gunicorn allows
you to do is it allows you to turn your
your bottle app or flask or Jango uh
basically into that web app it is it's
what is
presenting your python script as a web
application for users to come in um in X
that's sitting up here that is again
that reverse proxy server so that's that
helps with things like traffic and load
balancing and just making sure that the
process works better so theoretically
theoretically you could just use um
gunicorn you could just have your bottle
and you could just use gunicorn and you
could just point people from the outside
world directly to gunicorn um and again
to some degree that would work but then
there' be security issues and reli ility
issues and some other
things can Gorn work with something
other than python or only works with
python just going toor with something
other I know you use it with python it's
um uh it's a python web server right uh
I don't know if you can use it with
JavaScript I know you use it with
python okay thank you yep yeah uh
gunicorn is a python wsgi HTTP server
for Unix it is a prefork worker model
port from the Ruby unicorn project
unicorn server is broadly compatible
with other web servers there you go
that's the technical documentation yeah
and again like I said with a lot of this
stuff that's a big thing in the tech
world is sometimes the stuff has to
digest has to just digest and that
that's one of the reasons too like with
a lot of people that want to get into
Tech they have this thing where they're
like Eli I'm going to study 12 hours a
day seven days a week and I'm going to
be Bill Gates in six months or whatever
and is like no no you're not because it
take it takes a while to digest uh when
I was doing martial arts um one of my
instructors uh was teaching this this
Defense series anyways it was like a
Defense series and it was like uh four
weekends so it was two days each was
really really cool all kinds of wacky
real world situations um but one of the
things I asked him because he would only
do it once a month so you do two weeks
this month and two weeks the next month
and two weeks the next month whatever
else and again I'm one of those people
as lot younger at the time so I was like
hey you know can we make this more
accelerated can we do this faster one of
the interesting things again even in the
martial arts world he said you know Eli
I tried to do that before we used to do
like one week boot camps and this kind
of thing and he said what I found is
that people just didn't retain it for
whatever reason he was like in order to
retain this stuff he was like you know I
train you for two for two days and then
you go a the hell away for four weeks
and something in that process it allows
you to dig the information so when you
do the next two days you're actually
better and then you go away for four
weeks and the next two days the next two
days then actually trying to lump it all
together in in five days was actually an
inferior way of trying to actually make
somebody you know be able to do the
stuff in a useful fashion um so that's
one thing too like when you're when
you're learning this kind of stuff and
it seems confusing as hell just it's
okay don't worry we're g to keep using
it it g to keep coming back again and
again and again and again and at some
point Point you're like ah now I get it
or you'll become a florist that's up to
you anyways uh so this is going to be so
my app. service uh so when you create uh
this file so basically doing Nano Etc
system the blah blah blah so if this
file already exists you will access it
so if this is already here then you'll
see something you can edit it if it
doesn't exist it will create it one of
the nice things with Nano so we come
here and this is where you do not fat
finger make sure you do it right so you
have it up here in Brackets unit so you
have a description for what this
particular service is so my my this
particular service is my cool app again
you two things like that so people know
what the hell you're doing after equals
network. Target so this is actually a
very useful thing so basically what this
means is when the computer is booting
the service will start after your
Network starts so you can run into some
weird troubleshooting proc
troubleshooting problems where basically
when a service tries to start I think
it's three times in in Linux if a if a
service tries to start and fails it gets
three restarts and then Linux kills it
right so if you try to start this
service unicorn before your network is
started it's going to fail three times
in repetition and then it's not going to
work so basically what this says is do
not start this service until the network
work service has already started once
you get an IP address go for
it then we're going to go to the service
itself so user equals whatever the
username for that web app user that you
created www web user whatever the hell
else it doesn't matter what that name is
as long as it matches whatever name you
created before add user blah you put
that blah here user equals blah group
equals www hyphen data so www hyphen
data is a group that is just basically
the web user group that's that's default
created within Linux and so that is
going to be the group so again we start
talking about permissions 777 all the
kinds of permissions we're not going to
get into that today but you have
permissions for for the owner uh for the
group and then for everybody and so the
owner is this owner the group is this
working directory so basically where is
this app located so again how I have
this set up uh in Linux uh the user
profiles are saved in home so you go to
home whatever your username is and then
whatever the app folder is that is a
working directory so if you simply put
that app folder all the way it root it
would just be slapp folder right uh the
environment uh so this is for that VV
and again this will screw you up if
you're not using virtual environments
basically again the uh oh
modules and all that kind of stuff the
environment that you're going to be
using environment equals and this is
weird Ken don't ask me why I'm sure
there's a reason you'll notice this has
no quotation marks you'll notice this
has no quotation marks this has a
quotation mark why because it does
environment equals path equals home
again that username the app name the
venv name so again how we have it now
home um let's say
www my apppp
venv Ben right that's going to be the
environment and then you close those
double quotation marks then what is the
start going to be so how are we going to
be starting everything so exact start
equals home username app name V andv
name Ben gunicorn right so we've
installed gunicorn in that virtual
environment so this is how we're we're
triggering gunicorn then we're going to
do hyphen hyphen hyphen workers we're
going to use four workers just so you
can see this is just simply word wrap
here don't get don't get all lost in
word wrap right so basically workers 4
we're going to bind it to 127.0.0.1 call
in 8000 the script name so my app call
in the app name that we said before so
my app or app or whatever it is and that
is what's going to trigger gonor down we
have here for install want to buy so
it's multi-user so there going to be
multiple users that are going to be
getting the service and this is is
basically what you have to create for
this service to run so it's 127.0.0.1
again from a security standpoint this is
interesting so if you're if you're
running your own right you have auntu
you have an auntu desktop here uh and
you have a gooey environment on your
auntu desktop once this is running you
can go to Firefox or whatever you can
type in 127.0.0.1 call in 8000 and your
web app will show up so that's one of
the ways that you can test to make sure
gona the service and gona corn is
working
properly weird part is if you just
simply have a command line right if
you're just simply using um a server
basically a Ubuntu Server obviously you
don't have a guey and you don't have
Firefox and all that kind of stuff so it
can be a little harder to troubleshoot
now so one of the things that I would
say um with you folks especially in the
beginning when you're beginning to learn
all of this stuff when you're not
comfortable when you're not confident
with it uh have a Linux computer have
Ubuntu computer with Ubuntu desktop on
it so it's very easy for you to go
through and troubleshoot things and deal
with things in that graphical user
interface environment before you have to
dive in the deep end of only having a
command
line uh so once you've done that you're
going to hit control X you're going to
save so that actually saves a file make
sure to save the file if you don't save
the file and that's going to be the
other thing is do make sure when you run
this you run this as sudo what the hell
make sure you run this as sudu uh so
super user do basically this escalates
you to those root privileges and that
allows you to do stuff like this allows
you to modify these types of files if
you don't use Pudu if you just do Nano
blah blah blah you may get to the end of
this you go to save it and you don't
have permission to save it and then
that's its own misery so do make sure to
use Pudo once you've done that uh you're
going to run sudu system CTL demon
reload so what this is going to do is
it's going to re load all of the
services within that service directory
if you don't do that you can't do the
rest of it but don't worry if you try to
do the rest of it and you haven't done
it it'll give you a
warning um then what you're going to do
is you're going to say Pudu system CTL
start the app name right so basically
this is how you're going to start the
service for what you've created for
gunicorn to actually make sure that it's
running once you've started it you do
the start hopefully nothing fails out
then the next thing that you do is you
do Pudu system CTL enable and whatever
that is right so basically what this is
doing is is saying start this service
when the computer reboots so if all you
do is start it now as soon as the
computer reboots it'll it'll be off
because you haven't configured it auto
start and then you got to go through
figuring out how to start it if you do
enable basically what it says is every
time the computer reboots make sure to
run that particular service again if you
have a web browser H if you have a
browser on your system you you should be
able to go 127.0.0.1 col 8000 in the web
browser and be able to see and make sure
what's going on one of the other things
you can do here for troubleshooting
purposes is you can do Pudu system CTL
status the app name that you created and
that will show you the status uh to make
sure everything is running properly
right so if you went through here and
you fat fingered something you go to
start maybe you don't get an error for
some reason you go to status you might
see that it'll actually give you you
it'll say you know it failed and it
might actually give you some reason on
why it failed so status something should
put that in
here uh okay uh so then we get to uh
engine
X I thought i' modified this file
anyways uh so for engine X so engine X
has already been installed this is our
reverse proxy server right so you want
to do pseudo Nano
etcin xsites hyphen available uh and you
go to default uh so it's interesting uh
if you look at the documentation for
doing this uh a lot of the documentation
tells you uh to create a new site so a
new site for my app the problem is is if
you have the if a default is there and
it's configured you can run into some
weird problems when you're trying to go
to rout doesn't necessarily route
properly so especially if all you're
going to have you're just going to have
one web app basically one Whatever on
your server I would say you just simply
modify this default uh when you go in
there uh you basically going to delete
everything uh when you look at the
default configuration it's going to give
you a whole bunch of information you
don't really care about any of it get
rid of it uh and this is what you're
going to put in there so you're going to
say is server so you're going to say
listen at Port 80 right so we talk about
those TCP ports so uh gunicorn is
running at Port 8,000 if I try to
connect to Port 8,000 I have to do colon
8000 that doesn't work I want it to be
default so we're going to say listen at
Port 80 so I simply put in crappy app
and it goes in uh and this is the
default server server name is going to
be for 1 127.0.0.1 so that's
local location so this is basically
where you're going to be routing to so
if somebody comes to this location so
this location is the root the RO
directory uh so uh again basically
coming directly to your IP address for
the rout proxy pass hqp again 127.0.0.1
colon 8000 so this is where going to
pass from engine X to that gona corn
service that you've created uh you have
a whole bunch of stuff in here with a
proxy set
header it's remote address and that kind
of stuff and basically you need this for
that whole reverse proxy server for in
order to work
properly copy paste anyways and that's
uh that's basically all there is there
so we create the service create the
service so Zorn is running and then we
come down here and we point engine X at
gunicorn
then in order to verify that you didn't
screw up something with the G form
configur to make sure you didn't screw
up something with the engine X
configuration you do pseudo engine X
space hyphen T what this is going to do
it's going to look at that configuration
file and it's going to see if there was
any problems with that configuration
file if it is it'll try to spit out what
problems it has then what you're going
to do is you're going to do pseudo
system CTL restart the service for
engine X so just like we restarted the
Ser we started the service for our app
we're going to restart the service R un
next this is a big thing in the Linux
world and this is one of the things that
screws people up the most is forgetting
to restart Services more or less how
Linux works is when a service starts it
goes it looks at the configuration file
it brings in all the information from
the configuration file and then it runs
it from
memory well here's the thing if it's
running it from memory and you change a
configuration file what do you think is
going to
happen nothing nothing cuz is running it
from memory so whenever you make any
change in the Linux World make sure to
restart all relevant services so
basically when you restart the services
it will pull in those new
configurations and then away you go uh
that's the biggest thing for noobs the
reason noobs lose so much of their hair
is because they do all these
configuration changes and then it
doesn't work and they do more
configuration changes and it doesn't
work like what am I doing wrong it's
like restart the Ser restart you did it
right the first time hey you know 5
hours ago when you did it yeah that was
the right way you just didn't restart
the damn service so there's one thing to
remember today restart the D
service okay um and with that it should
be working um so if you go
to oh again uh you know um not that not
that this one uh
64225 one4 184 so imagine if I had a
domain name I just didn't bother with
the domain name with this so my crappy
app.com goes to that IP address once I
hit that IP address that goes to engine
X because I'm at P 80 it hits engine X
Eng X is a reverse proxy server so it
then sends me to gunicorn at Port 8000
gunicorn is running the app that I've
created and this is the web app that I
get that's basically what there is in
order to deploy
um a bottle app the other thing that you
can do is something called a socket you
know we talked about that
before and I have this at the
end what once you can deploy a bottle
app using 127.0.0.1 then bother with
sockets because sockets are its thing
oops
jock other people can ask questions too
I'm just going to put this on the table
jock jack isn't the only one with the
hand I think what's up Jack
so I remember a long time ago you said
we can never use port 80 how are we able
to use it
now understand question yeah yeah uh
because that's that's literally what um
engine X or Apache does when you install
either engine X or Apache or let's say
is or whatever they they are built to
provide websites at P 80 and so they
they have the permission to use port
80 so basically that's it like when you
install it you install it with admin
privileges when you install with admin
privileges I don't know a whole bunch of
configurations change on the back end
and so either engine X or aaki are able
to use port ad and you don't have to
worry about it so the easier so which
one is e like before you showed us how
to do 8080 and now you're showing is it
using 80 more complicated to just use
because we have to use these other I
guess systems to do it 80 or the
simplest way is just do 8080 kind of see
the question I'm asking yeah so okay so
yeah so basically what's happening here
right so again these are all different
things that are talking to each other so
engine
X
engine X is allowed to use P it's
allowed to use P right gunicorn when you
run gunicorn
is not allowed to use port 80 is
considered a protective
Port so basically the issue is you want
gunicorn to auto run but it's not able
to use port 80 so that's where uh and
you'll see with these ports
so there's other like standard HTTP
ports that people use they're just kind
of known uh so 8080 8080 is a standard
that I learned 20 years ago uh I guess
nowadays people are also using Port 8000
um actually doesn't really matter with
either Port 8880 or 8000 these are not
privileged ports they are not restricted
ports anybody on the system basically
can use them so when gunicorn uh starts
running and they run it under that that
that limited user account of www right
www does not have permission to use port
80 it can use either 8080 or 8,000 so
gunicorn runs your app under those ports
because that's a privilege that it's
able to do and then basically engine X
then points to that so when the user
comes from the outside world they're
going to go using Port 80 they're going
to hit engine X and then engine X routes
them and that's that whole reverse proxy
thing that I'm talking about routes them
to what's going on
internally thank you
yep yeah and that's where it's all and
again that's the whole thing you get
into like issues with permissions and
things so like like theoretically you
could run gunicorn on Port
80 but here's the thing in order to run
gunicorn Gorn under Port 80 you're most
likely have to have escalated privileges
such as root privilege admin type
privilege that type of thing and so
somebody is able to compromise your
bottle web
app and that bottle app has escalated
privileges all the system all of a
sudden your system gets hacked to high
hell right so basically engine X is
pretty lock down again I'll always say
pretty I always say pretty it's pretty
lock down right so anyways engine X is
pretty locked down it's able to use port
80 it's you know people have been using
it for years it should be fine so this
is able to use port 80 gunicorn when you
spin this up it uses these
non-privileged ports so you do not have
to have Escalade Privileges and that's
one of the ways that you keep your
system being secure because basically
that's what you can do is you can make
your app run at po 80 and again as long
as nobody tries to hack your system
you're fine again we talked about cyber
security right you need a vulnerability
you need a vector and you need an
attacker you can have a vulnerability
and you can have a vector if nobody
attacks it you're still fine somebody
does attack it you're screwed so yeah
that's why you kind of Step through this
whole
process that makes sense uh so we can do
socket so we can do socket so I'm just
going to go and take a look at this for
second um again this is his own thing
because
yeah again that's one of the issues with
like teaching you folks is
like there's good enough to do something
there's good enough to feel comfortable
deploying something and then there's
good enough actually teaching people how
to do it that's a s deal so basically
with the socket the nice part about the
sock is theoretically it's more secure
so everything is on the same box
everything is on the same box and your
next is on the same box
uh socket is on the same box you don't
have an IP address for the oh for
gunicorn so theoretically it's more
secure theoretically um and so this is
how you do it with socket uh so
description my cool app so this is a
service the service that we created
before we're going to create with a Saka
this time uh we're going to start it
after the network we're going to have
the user account so with this I just put
in www for my user account group equals
www hyphen data so here's the thing www
and www hyen data are going to have to
have ownership of your uh my app folder
did I have that up here yeah so pseudo
change ownership c h WN hyphen R for
recursive recursive means do this to
this folder and everything below home ww
so for this I did home www so basically
www and everything below I want the
owner to be www colon group owner P www
hyphen data so they own this folder and
everything below it and hopefully if you
do that it should work
hopefully um so anyways uh working
directory home www my app so my app you
had environment home www my app venv
Benin so this is getting you into that
virtual environment then exact Star Home
www my app venv ben gunicorn we do
hyphen Hyphen for workers four like we
did before but for the
bind I don't know if you can see that
on and you guys on Zoom so bind hyphen
hyen bind you're going to do Unix colon
mya. so what this is going to do is your
working directory is home www my app so
it's going to put this file called my
app. sock in that folder so basically uh
engine X is going to have to be able to
access this file and that's generally
where everything goes down we then have
my app my app so this is the script name
and this is the app name uh installed
for multi-user Target so this is this is
what's going to happen here so Unix
colon so instead of uh 0.0.0 or 17127
127.0.0.1 8000 we're going to do my app.
sock unex call on mya. sock um reload
start the service hopefully it works
again verify that the service is working
so pseudo system CTL status and what the
app name is again it is more likely that
this service is going to fail versus the
last one that I showed you because
you're actually writing to that folder
um so if if it can't write the service
will fail and you should get some some
error here if you plug in
status uh again we go to engine X sites
default like we did before and um
yeah so here uh basically it's a lot
like we did before uh listen at Port 80
default server server name is 127.0.0.1
location is root and then here you get
this weird ass thing so HTTP
colon Unix colon home ww myapp mya. sock
so HTTP but then we're using Unix to go
to where that's located um basically
everything else is I think the same
there you then verify that the engx
configurations are working and then you
restart uh the system uh so we go
over here right so this is this is what
is actually online and this is actually
using uh the
socket um
yeah so what we can see here hopefully
you can see on your 1080p screen right
um so home www Mya so you can see my my
app.py so this is my script here and
under this you can see my app. sock so
when I start the service what I want to
see is that that's there if I come here
and that file doesn't exist then nothing
the hell else is going to work because
it doesn't exist it has to be there in
order to be accessed again we can do um
oh we do pseudo um system
CTL status my app and again that's all
that's all just one line don't don't get
wrong and then when I do that basically
what you should see is active running
enabled you should see green you should
see green uh if you see red have fun
troubleshooting you're GNA have
troubleshoot it God knows what the hell
issue is going on there um and so with
that your service is going to need
permission to be able to write that file
to that folder and inine X is going to
need to have permission order to read
the file in the folder and that's going
to be the big thing here with um
changing the
ownership up here by changing H by
changing the ownership you're changing
the ownership recursively of the www
directory www is the owner www hyphen
data that's the group owner so hopefully
with that ownership when you set all
this up it'll work for
you hopefully hopefully uh beyond that
as far as troubleshooting purposes uh
are concerned again if you're using
Linux especially Ubuntu uh it does have
a built-in firewall again I talked about
layers of security previously and the
most important thing I want you to take
away from that class is if you screw
something up and you shut down your own
server you haven't made the world any
better right that's one of the big
things with like security things so ufw
is the built-in firewall to Linux
generally when you spin up a new droplet
ufw is not
running hopefully uh so you shouldn't
run into any firewall issues you
shouldn't run into firewall issues as
long as you set all this up all this up
right people go to Port 80 they drop in
one of the issues you might get into is
if you're using an older server or
especially a server that you've been
playing around with and at some point
you configured ufw
all these configurations can be correct
but if your firewall is blocking P 80
it's not going to matter none of it's
going to work because the firewall
blocking your Port 80s so know we can
get to that particular Port uh so that's
one of the things to think about like
with troubleshooting um and the rest of
it it's just going kind of going through
in plain uh again easiest way to set it
up is using that 1270 01 col 8000 for
the service uh once you get that under
your belt you can do the socket and then
you got your your your web app and it's
running and you too can say hello
Mom I'm on the web so that is that is
the class that is the
class anybody have any
questions there's no real Labs today
because again you've got to have a Linux
box one by way or the other you have to
have a Linux box or dig lotion or
whatever else uh so feel free to ask me
about this in the future like after
classes um but yeah we don't really have
because you got to have this uh let's
see here Jack what's
up
so my question is like we went over all
this today the first thing you were
saying is like
Linux Linux will be the best thing then
you have a Mac I have a Mac computer
would I be able to run any of this on
the
ma yeah you can run so gunicorn um not
that oh where do I have
it uh so this this right here this is
running on my Mac so when I run
um
oh there we go so when I run gunicorn
workers for bind 00 8000 my app my app
when I run this this is completely on my
Mac and I can go over here to 127 0
01800
and as you can see it's refreshing so
the goona corn par you can run on your
Mac um now God help you if you really
want to do
this you can run engine X on your
Mac have fun um you got to go through
the whole trouble shooting process on
that and God knows how well that's going
to work for you so you can you can run
engine X you can use your Mac as a full
web server everything I showed you today
you can build that stack again the issue
that you run into is then you've got to
do all the configurations for the max
stack and again I'm not doing this 20
different times so yes so theoretically
you can again I would get a Linux
computer that's where um you know I have
these old um this is what I have for
silicon Dojo so when silicon Dojo is the
inperson experience when we go back to
it these are our lab computers 2012
MacBook Pro bought them for $130 a piece
through in solid state drives these run
Ubuntu like a champ as long as you're
not doing a like real AI stuff they're
fine and so you can you can put Ubuntu
desktop on this and build everything and
test it and then you're only paying the
150 bucks or whatever it cost you or
again or if you have if you have some
computer that's Gathering dust somewhere
uh you can do that too or even um with
digital ocean so again so this is
running um the high M right this right
here is running on digil lotion and with
this so This is actually on the web it's
active on the web the whole n yards I'm
just paying six bu bucks a month that's
one thing that I will warn you um if you
decide to use like digital Ocean or
anybody else uh the $4 a month plans
like suck like you don't have to spend a
lot of money you don't to spend 20 bucks
a month just don't buy the $4 a month
plans spend some money buy the $6 a
month plan that'll work for you but
again but so you can use this and again
like with that like when you come here H
you come
here um there's this console and this
console is what takes you uh to this and
so you can actually I'm actually
essentially terminaling in to this
virtual Ubuntu box that's up there
paying six bucks a month and
yeah so okay so but look at two so two
options using digal otion to kind of do
this lab or I do have a
2012 MacBook Pro and I'm creating I'm
making that into my server to try to
test the stuff on in a sense correct if
I take that old old MacBook like you had
there and turn it into a server to try
to practice this one yeah yeah so
basically yeah all a server is is a
computer that provides services to other
ones that's really what all it is at the
end of the day so yeah if you you can
install Ubuntu just go there there's a
lot of um instruct it's basically just
flash USB drive and you can boot it up
and you install uh so yeah then you can
turn that into a Ubuntu server and do
all the project that did today
yep all right I'll try that and I any
questions just hit you up on LinkedIn
yep sounds good thank you
yeah okay Ash what's
up yeah first of all thank you so much
for all the
explanation and my query is suppose if I
have to host two different websites then
in that condition I need to have two12
running on the digital Ocean or is there
going to be be a single one which will
redirect to the engine X sitting on some
other box okay
so basically what happens in engine
because again engine X is also a
complicated piece of software I'm just
showing you a little bit um so what
happens whether you're using Indian X or
Apache or I if you're in the windows
world there's something called
vhosts um and so basically it's it's
virtual host but it's not virtual modern
stuff basically all that is is what
happens is you have your box and what
you do is you configure for the
different domain names that are on your
box so basically you say like my
app.com and then what that what's going
to happen is you're going to put
configurations there to Route users to
to something again either to an
index.html or to a web app or whatever
else uh if you put you know your
app.com that's a different vhost and so
you can put a different configuration to
Route uh to something somebody else and
so that's where like with GoDaddy years
ago they used to have a very very bad
reputation because they would put like a
thousand uh websites onto one of their
shared uh shared hosting plans and
that's what happened is basically you
can just replicate this out a thousand
times and then what what happens is when
you so my app.com so my app.com resolves
to the IP address of This Server your
app.com also resolves to the IP address
of this server but when when your
request comes in the server is going to
ask what website are you looking for so
even though both these users are going
to the same server one user is going to
my app.com other user is going to your
app.com and so they'll get routed
differently within the system but God
help me that's another class so yeah
that's that's on a technical level
that's how it works
though yeah thank you so much
y cool cool cool um yeah that's the
whole thing like with any of this stuff
whether it's gunicorn or whether it's
enginex you can you can probably do
about a 5 to 10 hour class like
literally on any one of these products
because that's where like with aach your
engine X I actually do want to do a
class on them in the future but again
it's
just like when you actually get into it
it's like oh there's a lot of stuff
there so anyways any more questions any
more
questions you get don't got any more
questions I G to go I've got a Halloween
party tonight
woohoo we're all going to get together
and be dressed up as ghosts looking out
at the Desolation that is hat
spell okay any more questions any more
questions any more
questions all right fair enough uh so
yeah so again I will be going to All
Things open uh this weekend and early
next week if you are in the Raleigh area
it does seem like a good conference if
you want to show up um we're going to be
doing more classes I'm going to start
putting these up because hopefully the
internet is fixed I had the comcat or
the I don't know the Spectrum person
here hopefully it got fixed I don't know
we'll find out so hopefully our
Internet's good kind to keep putting out
these classes and again like I said
we're going to have the live classes in
Asheville and in Raleigh the one thing
that I will request for anybody that's
still here that cares um I don't I don't
really care if you um become a member of
the other meetups but please do not RSVP
for an in-person
Meetup if you're in Catman do just
doesn't help anybody that's going to be
my one request there but if you are in
the area again like I say Nashville
we're going to start doing the inperson
classes and then Raleigh and really the
big thing with that again the thing for
you folks to be thinking about is there
is the value of relationships uh right
there's this idea like you know
everybody says like these truisms you
know it's not what you know it's who you
know and that actually doesn't go quite
far enough it's not what you know it's
not who you know it's who knows you the
most important conversations that will
affect your life forever will be
conversations you do not know happened
right you go to a party you go to an
event you're talking with somebody about
this weird ass AI project you're working
on they go to talk to somebody when
they're talking to somebody they're like
huh crap we've been trying to actually
do that type of thing you think you
could get me their number right and
that's that's where the real power in
our our industry comes from so that's
why we're going to be doing the the
inperson thing um so those are going to
be happening and we'll
see we'll see how it goes uh let's see
thanks for the class thanks for class
thanks keep up the work good deal cool
so that's all I got I will see you
probably next week we'll do some class
next week see y'all later