NOTE
This file was generated by Descript <www.descript.com>
1

00:00:00,250  -->  00:00:01,799
Hi guys and welcome back.

2

00:00:01,830  -->  00:00:06,420
In this section, we're going to be
deploying our Microblog app to Heroku,

3

00:00:06,450  -->  00:00:09,960
which is going to make it accessible to
anyone who has an internet connection.

4

00:00:10,290  -->  00:00:12,750
So we can share our app with our users.

5

00:00:13,055  -->  00:00:16,815
There are a few things that we have to
do in order to get our app on Heroku

6

00:00:16,835  -->  00:00:18,935
though, so let's get started with that.

7

00:00:19,385  -->  00:00:22,865
The first thing that we need is
to be able to tell Heroku what

8

00:00:22,915  -->  00:00:28,055
dependencies our app has, so what
packages we need to install from pip.

9

00:00:29,165  -->  00:00:36,275
In order to do that, we normally create
a file called requirements.txt in our

10

00:00:36,275  -->  00:00:41,375
folder, and in here, we're going to write
out all the dependencies of our app.

11

00:00:41,871  -->  00:00:46,491
As you can see, in here, I have
activated my virtual environment and

12

00:00:46,491  -->  00:00:51,111
we have already installed dependencies
using pip in previous videos.

13

00:00:51,471  -->  00:00:54,381
So if you can't remember exactly
what dependencies, your application

14

00:00:54,701  -->  00:00:57,091
needs, you can do pip freeze.

15

00:00:57,451  -->  00:01:00,881
And that is going to tell you all the
dependencies that we have installed.

16

00:01:01,866  -->  00:01:05,616
So by running this, you can see,
we get a few different ones and

17

00:01:05,646  -->  00:01:08,676
not all of these are dependencies
that we've installed manually.

18

00:01:08,676  -->  00:01:11,916
Some of these are dependencies
of other dependencies.

19

00:01:12,096  -->  00:01:16,716
For example, when we install
flask, it  installs Jinj2 for us.

20

00:01:16,926  -->  00:01:21,366
So both of these appear in pip freeze,
but we don't have to put all of

21

00:01:21,366  -->  00:01:23,916
these in our requirements.txt file.

22

00:01:24,621  -->  00:01:27,381
Instead, what we have to do
here is put the stuff that we

23

00:01:27,381  -->  00:01:28,761
actually installed manually.

24

00:01:28,761  -->  00:01:31,751
So that's flask and pymongo[srv].

25

00:01:33,561  -->  00:01:37,281
These are the two libraries that we
installed, and when we install these,

26

00:01:37,671  -->  00:01:39,651
that we'll install all of these.

27

00:01:40,341  -->  00:01:44,901
You can, if you want, grab all of
this, copy it and paste it in here.

28

00:01:45,141  -->  00:01:45,981
And that's totally fine.

29

00:01:45,981  -->  00:01:50,331
And what that will ensure is that
you install exactly these versions of

30

00:01:50,331  -->  00:01:51,861
the libraries that we have right now.

31

00:01:52,558  -->  00:01:57,028
Installing specific versions of a
library can be helpful because libraries

32

00:01:57,058  -->  00:01:59,068
change when a new version gets released.

33

00:01:59,308  -->  00:02:03,478
So by installing the exact versions
that you used when you were coding

34

00:02:03,478  -->  00:02:07,438
your app, that can make sure that the
app doesn't break later on when new

35

00:02:07,448  -->  00:02:08,908
versions of the libraries come out.

36

00:02:09,418  -->  00:02:14,298
If we don't write the version,
for example, equal, equal 1.1.2.

37

00:02:14,938  -->  00:02:19,768
If we don't write this, then we will
install the latest version of flask.

38

00:02:19,818  -->  00:02:23,215
And like I say, over time,
flask will get updates and those

39

00:02:23,215  -->  00:02:25,825
updates may break past apps.

40

00:02:25,975  -->  00:02:29,605
So by installing the latest version
of flask, every time it may come a

41

00:02:29,605  -->  00:02:33,205
point later down the line where our app
will not work, because something that

42

00:02:33,205  -->  00:02:35,245
used to work in flask no longer works.

43

00:02:36,550  -->  00:02:39,070
However, I'm not particularly
worried about that just now.

44

00:02:39,100  -->  00:02:43,150
So I'm going to leave it as is, but later
on, when you're making more production

45

00:02:43,150  -->  00:02:47,920
ready applications, you may want to
stay safe and ensure that specific

46

00:02:47,920  -->  00:02:49,300
versions of a library are installed.

47

00:02:49,750  -->  00:02:51,790
But again, for now, we don't
really care about that.

48

00:02:52,000  -->  00:02:54,760
And we want the latest versions
of apps so that we get any

49

00:02:54,760  -->  00:02:56,590
improvements that come with those.

50

00:02:57,290  -->  00:03:01,130
In the future, if something does
break unexpectedly when you release

51

00:03:01,220  -->  00:03:04,610
your app or you deploy your app,
just check, make sure that it isn't

52

00:03:04,640  -->  00:03:07,970
a breaking change in one of your
dependencies, because that can happen.

53

00:03:08,666  -->  00:03:12,056
Now that we've got the
requirements.txt file, we can use

54

00:03:12,056  -->  00:03:13,946
it to install our requirements.

55

00:03:14,456  -->  00:03:19,676
Normally you do that with pip
install -r requirements.txt.

56

00:03:20,006  -->  00:03:22,466
Obviously we already have the
requirements installed, so we don't

57

00:03:22,466  -->  00:03:25,796
have to run this, but this is how
you would install everything that

58

00:03:25,796  -->  00:03:28,256
is in requirements.txt using pip.

59

00:03:28,496  -->  00:03:29,906
But we don't have to run it at this point.

60

00:03:30,176  -->  00:03:34,706
However, Heroku our deployment mechanism
that I'll cover in a later video

61

00:03:34,926  -->  00:03:38,281
will run that, so it will install
everything that is in this file.

62

00:03:39,481  -->  00:03:40,741
All right, that's
everything for this video.

63

00:03:40,741  -->  00:03:44,251
I just wanted to guide you through
requirements.txt and how it works.

64

00:03:44,401  -->  00:03:47,101
In the next few videos, we're
going to be using these and a few

65

00:03:47,101  -->  00:03:49,291
other files to deploy to Heroku.

66

00:03:49,501  -->  00:03:50,491
So I'll see you in the next one.
