Okay, so now that we have built our application, we would like to deploy this for free right.
And for this we're going to be using a platform called Render Comm.
Go ahead and create an account.
Then you will be in the maybe dashboard.
So if you clicked it you'll be able to go ahead and see your past projects.
So this is the demo application that I have deployed.
But just ignore this.
Probably you're not going to have anything here.
We'll just go ahead and create a new web service.
But more on this later in the video.
First, let's take a look at the terminal.
So when we run the app.py file.
So if we just go very above we can see here it says this is a development server.
Do not use it in a production deployment.
Use a production VC server instead.
So what does that mean.
So that means basically you need a VC dot pi for the deployment, uh, to make the deployment happen.
Really.
And in this file we'll take to just run our app dot pi file.
So we'll go ahead and just from, let's say from app import app and Socket.io.
Okay.
So since we have these variables we can go ahead, grab it from the app Dot Pi and just their names.
And we'll just run this uh, file basically.
So we'll say if name and just make sure you put double underscores if it is equal to main.
In this case we would like to, uh, initialize Socket.io and run our application.
And since this is in the production, we don't really need to get this, uh, debugging logs right.
When you put debug to be equal to true, you get all these, but if you don't put, you're not going
to get anything, uh, which is fine for the production.
Okay.
So this is the first file that we would need.
And we also need, uh, I think two different, um, like, packages.
Let's go ahead.
Kill this with Ctrl C, and we will say pip install, uh, unicorn which stands for Green Unicorn.
And we're going to see what that means.
And we also want to get the event.
Let let's install these packages.
And here I can maybe put a comment so that you can really see it in the source code.
So green Unicorn and Vsti which stands for Web Server Gateway Interface, are both components used to
deploy your Python web applications and specifically in Flask or Django applications.
And since we are using flask, uh, we're using them.
Right.
So this is going to be needed in the render.com when we try to deploy it.
So the other thing we need is to get the requirements file.
So let's see uh how it's going to look like first I'll just say CLS to clear up my console.
And I will say pip freeze.
And I'll say like greater than uh Rico mints dot txt I think I have a typo here, let's say requirements.
Okay, so I just had a typo, I fixed it.
And if you are on macOS or Linux this is going to be Pip three, right.
But I'm on windows.
That's what I'll be doing.
So once you run this it's going to create the requirements file.
And it's going to show you which packages you're using in this project.
And we're going to need this when we deploy it.
Because the render need needs to install all these packages to be able to run this virtual environment,
right, so that it can run the application.
So I think with this that's going to be it.
We can deactivate it now and we're going to go ahead and create a git ignore git ignore file so that
we don't really push our uh, virtual environment files into the GitHub, which is not really needed.
So I'll just, uh, copy this and paste it.
You can get it from the GitHub repo from this file where we just, uh, ignore the virtual environment,
ID files, environment variables, things like that.
Okay.
Once you save this we're going to go ahead.
Just say git init and let's say git commit m Initial commit.
Okay.
Obviously we first need to add all of them right.
Git add all.
And let me just grab this so that you can see it.
Okay.
Git commit m.
Now we can say initial commit.
Okay.
Now we'd like to deploy this uh to the GitHub.
So I'll go ahead and create a GitHub repo.
Okay.
So I'll just go ahead and give it a name.
Let's say Python chat.
I will make this private.
But while you're watching this video it's going to be public for now.
I'll just go with private.
And if you are following following along you can go with the public option.
Okay.
Let's say create the repo.
We're going to go ahead grab this thing and just paste it into our terminal.
So that is going to go ahead push this code to the GitHub.
Okay.
Now that we got our files right it is working as expected.
We can go into the render dashboard I'll say create new web service.
And we will pull this GitHub repo right.
Which is this one that I have just created.
Python chat.
Let's say connect and we need to have the build command as well as the start command.
Now basically it's going to first run this command.
Let me just zoom in.
It will say hey just take a look at the requirements.txt file and install all these packages into the
render server.
Right.
So that it can run our application.
So it would go ahead install the Socket.io flask.
Uh, green unicorn greenlet like all these packages that we need.
And then for the start command, we need to run a command so that we can run this that is compatible
with the scikit I o.
So instead of leaving this as default we will say green unicorn.
Just put one space dash dash worker class and we'll say event let.
So this is why we installed that package dash w one vs gi and app.
So we call this as vs GI is because this is what we call the file name right.
now we're going to go ahead.
Select the free plan which is completely fine for the side projects.
It just goes inactive when you don't really visit it more than 15 minutes.
And when you visit that it's going to take about maybe 30s to one minute, then it's going to, uh,
connect to it.
Okay.
Let's just say deploy this web service.
Hopefully it should be live without any issues.
So this is going to take a little bit of time.
We got a URL right.
So once this is live I'll just be right back.
So here I just got a new notification here.
It says in progress.
Successfully installed all these packages by taking a look at the requirements file and build was successful.
Hopefully it should be alive just in a second, but this takes a little bit time.
So let's just wait for this.
And there we go.
It just says live.
Your service is live.
Let's click to it and just visit it okay I'll just copy this.
And here we can see here it says you just joined to the chat, right?
Um, let me just copy this, paste it, and just put them side by side.
So here it says like this user joined the chat.
Let me just put them side by side and let's just test this out.
I'll just say hey here we can see it is just working as we had in the development server, right.
And if we leave it it's just going to say this user left the chat.
We can update our name let's say John Doe.
It's going to notify everyone.
And we can even have multiple different sessions.
So let me just create more than one right.
So this is the second one.
Let's open up another tab.
Paste it.
And I'll just put all of them side by side.
So here let's say hey everyone sent a message and it is just live in every single tab right.
And if we just leave this it's going to say this user just left the chat and it is working in real time.
So with that that's going to be it for this entire application.
I hope you liked it and I'll see you in the next one.