This is new video, and the previous video that I had it before in this course was how to deploy our
API on Heroku.
But Heroku have changed its pricing strategy.
So that's why I decided to rerecord this section, and I will show you a different platform that we
can deploy our application.
So the platform that we can deploy it is called Pythonanywhere.
We can go to W-w-w Pythonanywhere.
Com and then we can actually go here to pricing.
And you can see here we have create a beginner account.
So this is what you will need to do.
So we have a limited usage of pythonanywhere.
But it will be good enough for putting our API up and running.
So once you create our account we can log in.
And we have the pricing here.
But I can go to my dashboard and this is what I see.
So basically my username here in that account is like this.
So my application will also be as a part of the URL.
So.
So whatever you create a username this will be part of the URL for your application.
So what we need to do is we need to do a few things.
So first thing first we need to move your our code to a Python anywhere.
And we also need to create a web app.
So if I will go here web apps open web app I don't have any applications here at the moment.
So we'll go to dashboard and we need to move our code into the platform.
One way will be to you can go to the files.
We can see.
Click on a file so I can click files here.
This is what the files are on the server at the moment.
And if you don't want to use the git as I as I will use because you don't have your project on a git,
what you could do is you can zip it and upload it here.
So that would work exactly the same as I will do.
But since I have my projects here on my git so we can go to this link here and we put our application
there, what I can do is I can actually use a JIT to get the code.
If you struggle with how to do it, there is a handy page here.
Help Pythonanywhere comment pages deploy existing Django project.
And that's actually very important because if you create, if you go here and go to the web and create
a new application, and we'll do next, you have an option here for a Django, but do not use this one
as this is for the new Django.
We already have our project, so we will need to do it in a different way.
And so I will go to consoles here and if I will create a new console I will open the bash console here.
So click on this one.
And that is our terminal.
So basically I can I'm at the moment on the server and I can run some terminal commands to deploy my
application there.
So first thing first what we need to do.
And if you go to this tutorial it's basically ask us to clone the repository and I will do that.
So I will go to my repository which is API, and I will click this one and I can copy that URL.
I can go here and then I can do git clone and my URL.
So basically this will be cloned and I have it here.
So if I do lf you see this folder has been created for me and I have it there.
So if you don't want to use git you can upload it and unzip it here in the folder and it will be exactly
the same.
So what next we need to do.
Basically we need to create virtual environment.
So if I will copy this line of code here and I will go here, what I can do is I can say.
Movie creator virtual environment.
This is the name of the virtual environment.
So I will make virtual environment using Python 3.1.
This is the version that we are using.
That's the latest one available on Python anywhere.
And then this is the name of course you can name it whatever you like.
I will have it like this.
Okay, this has been done.
So we have virtual environment already there.
And you can see here in the brackets the name of my virtual environment.
That means it is activated.
So what we need to do is we need to install few things.
So if you go here it will actually tell you to install Django.
But we also need to install few other things.
What we could do is we could have requirements.txt.
So if we don't have that requirements.txt here, what we could do is in our project I will go to terminal
here.
And if we would like to have our requirements, which is basically a list of the things that we need
to install, what I can do is I can use pip freeze and then greater than sign and I can do requirements.txt.
So basically what I will do is pip freeze will tell me exactly what is installed here and virtual environment
and put it in the requirements.txt file so you can see this file has been created.
I can open this.
And this is basically the things that we need to install just to have our application running.
Then you can commit it and you will have that in a git.
Or you can copy that and you can create that on on the server.
So I've created that locally.
Normally I will have that in a git.
But if I will go here I can go to console.
I can say vim which is a program that will allow me to edit files remotely.
And I can do re quire mint txt.
So basically I'm creating a new file here in that folder and I can do I which is insert and I can paste
it whatever I have created over there.
So basically I don't need to move that file.
I can create that on the go.
So I will do escape and then colon and then x that will save the file and it will be there.
So if I will do ls here.
You see I have that file here.
So if I have that file with all the requirements, I can pip install this.
Or I could do pip install Django, Django, Rest framework pillow and Django course headers.
I can do it manually or I can do pip install r like recursive and then requirements.txt.
So install everything from that file.
So that may take a while because this free version is a kind of slow.
But it will be installed there.
So we can go back to next step.
What we need to do is uh, we have done this, then we can have setup your web app and um, Wsgi.
So basically what we need to do is we need to go out from this console once it will be ready.
And we need to create our application.
So let's wait until that will finish.
And that has been done here.
So we can see here that it has been installed.
So what you can do is I can right click here.
And I can go to web.
And I don't have any web application.
So I will create a new web application here.
I will click next.
So this is our free version.
Basically this will be URL of my application.
So this is the username I'm logged in with.
And then that's the rest of the URL.
If you want to have like custom one then you need to upgrade it and go for a paid package.
So I'll click here.
And this is what I said before you don't pick Django Hero because this is what we we don't want to create
a Django.
We want to we have already our version.
So we will pick manual.
And here I can select the version.
I will select the latest version 310.
So here manual configuration.
So we need to do that here.
So I will click next.
And then that application will be created for us.
And here we have it okay.
So we successfully moved our code to a server and we created an application.
In the next video we will need to configure that to fully working with whatever we need to have in our
application.