WEBVTT

00:02.900 --> 00:09.260
This is new video, and the previous video that I had it before in this course was how to deploy our

00:09.260 --> 00:10.580
API on Heroku.

00:10.610 --> 00:13.580
But Heroku have changed its pricing strategy.

00:13.580 --> 00:19.880
So that's why I decided to rerecord this section, and I will show you a different platform that we

00:19.880 --> 00:21.650
can deploy our application.

00:21.950 --> 00:26.480
So the platform that we can deploy it is called Pythonanywhere.

00:26.510 --> 00:29.750
We can go to W-w-w Pythonanywhere.

00:29.750 --> 00:33.320
Com and then we can actually go here to pricing.

00:33.320 --> 00:36.170
And you can see here we have create a beginner account.

00:36.170 --> 00:38.090
So this is what you will need to do.

00:38.120 --> 00:42.230
So we have a limited usage of pythonanywhere.

00:42.230 --> 00:46.430
But it will be good enough for putting our API up and running.

00:46.430 --> 00:49.940
So once you create our account we can log in.

00:52.280 --> 00:53.780
And we have the pricing here.

00:53.780 --> 00:56.540
But I can go to my dashboard and this is what I see.

00:56.540 --> 01:01.880
So basically my username here in that account is like this.

01:01.880 --> 01:06.210
So my application will also be as a part of the URL.

01:06.210 --> 01:06.510
So.

01:06.690 --> 01:11.700
So whatever you create a username this will be part of the URL for your application.

01:11.700 --> 01:14.700
So what we need to do is we need to do a few things.

01:14.700 --> 01:19.650
So first thing first we need to move your our code to a Python anywhere.

01:19.650 --> 01:21.990
And we also need to create a web app.

01:22.020 --> 01:27.540
So if I will go here web apps open web app I don't have any applications here at the moment.

01:27.540 --> 01:32.880
So we'll go to dashboard and we need to move our code into the platform.

01:32.880 --> 01:35.700
One way will be to you can go to the files.

01:35.700 --> 01:36.270
We can see.

01:36.300 --> 01:38.490
Click on a file so I can click files here.

01:38.520 --> 01:42.240
This is what the files are on the server at the moment.

01:42.240 --> 01:48.420
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,

01:48.450 --> 01:51.000
what you could do is you can zip it and upload it here.

01:51.000 --> 01:54.360
So that would work exactly the same as I will do.

01:54.390 --> 02:03.240
But since I have my projects here on my git so we can go to this link here and we put our application

02:03.240 --> 02:09.040
there, what I can do is I can actually use a JIT to get the code.

02:09.040 --> 02:13.390
If you struggle with how to do it, there is a handy page here.

02:13.390 --> 02:17.890
Help Pythonanywhere comment pages deploy existing Django project.

02:17.890 --> 02:24.970
And that's actually very important because if you create, if you go here and go to the web and create

02:24.970 --> 02:31.660
a new application, and we'll do next, you have an option here for a Django, but do not use this one

02:31.660 --> 02:34.210
as this is for the new Django.

02:34.210 --> 02:37.900
We already have our project, so we will need to do it in a different way.

02:38.140 --> 02:45.400
And so I will go to consoles here and if I will create a new console I will open the bash console here.

02:45.430 --> 02:46.480
So click on this one.

02:46.480 --> 02:48.280
And that is our terminal.

02:48.280 --> 02:55.270
So basically I can I'm at the moment on the server and I can run some terminal commands to deploy my

02:55.270 --> 02:56.260
application there.

02:56.290 --> 02:58.060
So first thing first what we need to do.

02:58.060 --> 03:03.730
And if you go to this tutorial it's basically ask us to clone the repository and I will do that.

03:03.730 --> 03:11.000
So I will go to my repository which is API, and I will click this one and I can copy that URL.

03:11.720 --> 03:18.740
I can go here and then I can do git clone and my URL.

03:19.190 --> 03:21.680
So basically this will be cloned and I have it here.

03:21.680 --> 03:29.150
So if I do lf you see this folder has been created for me and I have it there.

03:29.150 --> 03:36.050
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

03:36.050 --> 03:36.710
the same.

03:36.710 --> 03:38.450
So what next we need to do.

03:38.480 --> 03:40.820
Basically we need to create virtual environment.

03:40.820 --> 03:48.530
So if I will copy this line of code here and I will go here, what I can do is I can say.

03:51.530 --> 03:55.340
Movie creator virtual environment.

03:55.340 --> 03:57.470
This is the name of the virtual environment.

03:57.470 --> 04:01.310
So I will make virtual environment using Python 3.1.

04:01.340 --> 04:03.230
This is the version that we are using.

04:03.230 --> 04:05.750
That's the latest one available on Python anywhere.

04:05.750 --> 04:09.880
And then this is the name of course you can name it whatever you like.

04:09.910 --> 04:11.710
I will have it like this.

04:15.190 --> 04:16.600
Okay, this has been done.

04:16.600 --> 04:18.760
So we have virtual environment already there.

04:18.760 --> 04:22.480
And you can see here in the brackets the name of my virtual environment.

04:22.480 --> 04:24.370
That means it is activated.

04:24.370 --> 04:27.400
So what we need to do is we need to install few things.

04:27.400 --> 04:32.080
So if you go here it will actually tell you to install Django.

04:32.080 --> 04:35.260
But we also need to install few other things.

04:35.260 --> 04:39.700
What we could do is we could have requirements.txt.

04:39.760 --> 04:46.870
So if we don't have that requirements.txt here, what we could do is in our project I will go to terminal

04:46.900 --> 04:47.350
here.

04:47.350 --> 04:52.510
And if we would like to have our requirements, which is basically a list of the things that we need

04:52.510 --> 05:04.060
to install, what I can do is I can use pip freeze and then greater than sign and I can do requirements.txt.

05:04.270 --> 05:10.550
So basically what I will do is pip freeze will tell me exactly what is installed here and virtual environment

05:10.550 --> 05:14.840
and put it in the requirements.txt file so you can see this file has been created.

05:14.840 --> 05:15.710
I can open this.

05:15.710 --> 05:20.870
And this is basically the things that we need to install just to have our application running.

05:20.900 --> 05:23.510
Then you can commit it and you will have that in a git.

05:23.510 --> 05:27.860
Or you can copy that and you can create that on on the server.

05:27.860 --> 05:29.510
So I've created that locally.

05:29.540 --> 05:31.430
Normally I will have that in a git.

05:31.430 --> 05:35.330
But if I will go here I can go to console.

05:35.330 --> 05:41.570
I can say vim which is a program that will allow me to edit files remotely.

05:41.570 --> 05:47.540
And I can do re quire mint txt.

05:47.600 --> 05:56.570
So basically I'm creating a new file here in that folder and I can do I which is insert and I can paste

05:56.570 --> 05:58.310
it whatever I have created over there.

05:58.310 --> 06:00.680
So basically I don't need to move that file.

06:00.680 --> 06:02.270
I can create that on the go.

06:02.300 --> 06:08.900
So I will do escape and then colon and then x that will save the file and it will be there.

06:08.900 --> 06:10.310
So if I will do ls here.

06:10.310 --> 06:12.150
You see I have that file here.

06:12.150 --> 06:17.220
So if I have that file with all the requirements, I can pip install this.

06:17.220 --> 06:25.080
Or I could do pip install Django, Django, Rest framework pillow and Django course headers.

06:25.080 --> 06:31.710
I can do it manually or I can do pip install r like recursive and then requirements.txt.

06:31.740 --> 06:34.020
So install everything from that file.

06:34.020 --> 06:38.910
So that may take a while because this free version is a kind of slow.

06:38.910 --> 06:40.830
But it will be installed there.

06:40.830 --> 06:42.810
So we can go back to next step.

06:42.810 --> 06:52.110
What we need to do is uh, we have done this, then we can have setup your web app and um, Wsgi.

06:52.140 --> 06:57.990
So basically what we need to do is we need to go out from this console once it will be ready.

06:57.990 --> 07:00.030
And we need to create our application.

07:00.030 --> 07:02.190
So let's wait until that will finish.

07:03.270 --> 07:04.980
And that has been done here.

07:04.980 --> 07:07.920
So we can see here that it has been installed.

07:07.950 --> 07:10.230
So what you can do is I can right click here.

07:10.230 --> 07:11.820
And I can go to web.

07:11.820 --> 07:14.350
And I don't have any web application.

07:14.350 --> 07:17.410
So I will create a new web application here.

07:17.440 --> 07:18.610
I will click next.

07:18.610 --> 07:21.220
So this is our free version.

07:21.220 --> 07:24.130
Basically this will be URL of my application.

07:24.130 --> 07:27.010
So this is the username I'm logged in with.

07:27.250 --> 07:29.230
And then that's the rest of the URL.

07:29.230 --> 07:34.090
If you want to have like custom one then you need to upgrade it and go for a paid package.

07:34.120 --> 07:35.290
So I'll click here.

07:35.290 --> 07:41.470
And this is what I said before you don't pick Django Hero because this is what we we don't want to create

07:41.500 --> 07:41.950
a Django.

07:41.980 --> 07:45.040
We want to we have already our version.

07:45.040 --> 07:46.450
So we will pick manual.

07:46.450 --> 07:48.370
And here I can select the version.

07:48.370 --> 07:50.740
I will select the latest version 310.

07:50.770 --> 07:52.780
So here manual configuration.

07:52.780 --> 07:54.400
So we need to do that here.

07:54.430 --> 07:55.480
So I will click next.

07:55.480 --> 07:58.660
And then that application will be created for us.

08:00.520 --> 08:02.920
And here we have it okay.

08:02.950 --> 08:08.620
So we successfully moved our code to a server and we created an application.

08:08.620 --> 08:14.770
In the next video we will need to configure that to fully working with whatever we need to have in our

08:14.770 --> 08:15.670
application.
