1
00:00:01,630 --> 00:00:07,700
Hey welcome to this new lecture and in this lecture, what I'm going to do is I'm going to deploy my web site

2
00:00:07,810 --> 00:00:14,700
to Heroku, so in a live server so that everyone can access it and yeah our Web site is currently

3
00:00:14,700 --> 00:00:18,140
working well.

4
00:00:18,660 --> 00:00:29,340
Let me quickly execute that script1.py and maybe go to Google Chrome localhost 5000.

5
00:00:29,360 --> 00:00:30,780
And yeah, it's working well.

6
00:00:31,230 --> 00:00:34,530
Let me check the plot subdomain where we have our financial plot.

7
00:00:37,710 --> 00:00:39,440
Yeah it looks good.

8
00:00:40,410 --> 00:00:50,490
Well we could make an improvement before deploying to Heroku and that would be to add an navigation menu for

9
00:00:50,490 --> 00:00:51,930
the plot

10
00:00:52,140 --> 00:00:52,890
web page.

11
00:00:52,950 --> 00:00:54,840
For now we have to enter it manually.

12
00:00:54,840 --> 00:00:56,010
We have to type it in.

13
00:00:56,010 --> 00:01:00,910
So let me quickly go ahead and create a reference here.

14
00:01:01,200 --> 00:01:08,020
So just as we did with home and about we do with plot.

15
00:01:08,040 --> 00:01:15,490
So we refer to the plot function there, and then a name for the menu plot.

16
00:01:15,610 --> 00:01:26,040
And yeah, that should do it. Go there and reload with control R, and yeah now plot is part of the menu.

17
00:01:26,550 --> 00:01:34,860
So yeah that was the quick change. Now I can close this, this as well, control C to interrupt the app.

18
00:01:35,120 --> 00:01:42,860
And yeah, about the deployment process I explained how to deploy a Web site a flask Web sites to Heroku

19
00:01:43,530 --> 00:01:46,710
in the lecture named deploying to Heroku.

20
00:01:47,330 --> 00:01:53,400
So please go through that lecture if you haven't taken that already. In this election I'll basically go

21
00:01:53,400 --> 00:01:58,720
through the same steps, but I'm not going to stop and explain them in detail.

22
00:01:58,980 --> 00:02:04,420
So if you have a taken of lecture deploying to Heroku it's not necessary to go through that again.

23
00:02:05,040 --> 00:02:10,830
And yeah, what we want to do now is you know first make sure you are in the same directory where

24
00:02:10,830 --> 00:02:14,900
your Python file so that a demo

25
00:02:15,000 --> 00:02:23,520
in my case here, and yeah we go. Demo here your script1.py is in that directory.

26
00:02:23,530 --> 00:02:24,390
And yeah.

27
00:02:24,460 --> 00:02:29,870
We'll go ahead and create those three files, the requirements.txt file, the runtime.txt

28
00:02:29,920 --> 00:02:31,160
and the proc file.

29
00:02:31,410 --> 00:02:39,120
So I should point to virtual and script and pip freeze.

30
00:02:41,640 --> 00:02:50,250
And requirements.txt and yeah, what that does is it generates a list of Python packages that you have

31
00:02:50,250 --> 00:02:52,800
in your virtual installation.

32
00:02:53,220 --> 00:02:55,940
So you know why that is necessary.

33
00:02:56,250 --> 00:03:01,900
You want to tell Heroku what was to install in their system.

34
00:03:02,100 --> 00:03:02,610
And then we need

35
00:03:06,270 --> 00:03:10,160
a proc file without an extension.

36
00:03:10,590 --> 00:03:16,400
So Windows users make sure in the folder search options under view this option here,

37
00:03:16,400 --> 00:03:18,300
hide extensions for known file types

38
00:03:18,470 --> 00:03:22,670
is unchecked as I have, good, and open

39
00:03:22,670 --> 00:03:35,700
that with Atom maybe and write web gunicorn and then script1.

40
00:03:36,010 --> 00:03:38,700
Colon again and then app.

41
00:03:38,780 --> 00:03:47,250
So the name of the Python file and the name of the variable holding the flask instance which is this one here. Great!

42
00:03:47,580 --> 00:03:56,700
You want to save that and I forgot something actually I forgot to install Gunicorn or so I'm going to go

43
00:03:56,700 --> 00:04:13,430
ahead and install that, oh sorry! Pip install gunicorn. Gunicorn which is an http server that Heroku needs to run our application.

44
00:04:14,140 --> 00:04:21,360
And now you need to run pip freeze again so that you include Gunicorn in your requirements.txt.

45
00:04:21,360 --> 00:04:23,820
And yeah, Gunicorn is there now.

46
00:04:23,820 --> 00:04:28,110
Great, proc file, requirements.

47
00:04:28,170 --> 00:04:35,410
We also need another file runtime.txt.

48
00:04:35,730 --> 00:04:37,400
That would be python

49
00:04:37,830 --> 00:04:40,620
a dash 3.5.1

50
00:04:50,330 --> 00:04:52,330
And save it. Good!

51
00:04:52,490 --> 00:04:54,070
Now we should be good to go.

52
00:04:54,230 --> 00:04:56,770
So go ahead and log in with Heroku.

53
00:04:57,100 --> 00:04:57,990
Heorku log in.

54
00:05:00,920 --> 00:05:08,580
Let me expand this.

55
00:05:08,630 --> 00:05:13,130
These are the credentials that you use to create an account in Heroku.

56
00:05:13,980 --> 00:05:22,880
I was logged in successfully so my apps in Heroku should be ardit and test 702. Yeah.

57
00:05:23,120 --> 00:05:27,560
These are my two apps and I want to create a new one Heorku create

58
00:05:27,760 --> 00:05:31,140
maybe arditbokeh.

59
00:05:34,090 --> 00:05:34,840
All right.

60
00:05:34,960 --> 00:05:36,430
That was good.

61
00:05:36,900 --> 00:05:41,620
Then go ahead initialize a git repository. Good.

62
00:05:41,840 --> 00:05:46,990
We got the dot git folder added in our current directory and then go ahead.

63
00:05:47,050 --> 00:05:51,040
And add the files, good.

64
00:05:51,420 --> 00:05:54,670
Then commit the changes.

65
00:05:54,750 --> 00:05:55,720
M and first commit.

66
00:05:59,250 --> 00:06:00,520
9 files changed.

67
00:06:00,540 --> 00:06:02,400
Great.

68
00:06:02,520 --> 00:06:06,450
And then you want to connect to your...

69
00:06:06,450 --> 00:06:09,290
In my case would be arditbokeh app.

70
00:06:09,360 --> 00:06:16,260
So Heroku git:remote app and ardit

71
00:06:16,480 --> 00:06:18,470
bokeh, yeah.

72
00:06:19,260 --> 00:06:28,440
Good, that git was set to that app. Heroku info this is not required but you can check to see if you're

73
00:06:28,440 --> 00:06:30,040
really connected to arditbokeh.

74
00:06:30,140 --> 00:06:36,360
And yeah, I got the data here for arditbokeh, so that means I'm connected to my app.

75
00:06:36,460 --> 00:06:44,630
Now if you push the changes those changes will be pushed to this app so git push Heroku master and execute.

76
00:06:48,480 --> 00:06:55,830
Python app detected installing Python 3.5.1 so Heroku is installing a the Python version that we

77
00:06:55,850 --> 00:06:59,040
inserted in the runtime.txt file.

78
00:06:59,370 --> 00:07:09,290
Now it's installing the packages that we inserted in the requirements.txt, so Numpy, Pandas, and Gunicorn.

79
00:07:09,510 --> 00:07:14,910
Flask and some Flask dependencies like itsdangerous, Jinja2

80
00:07:15,210 --> 00:07:23,300
and so on. You'll have to wait a while there. Downloading Pandas may take a while.

81
00:07:23,370 --> 00:07:29,080
Pandas took a while to download in Heroku. Now Pandas is installing.

82
00:07:29,910 --> 00:07:37,560
You can see Flask, install for Flask finished with statous done. So Flask was installed correctly and

83
00:07:37,560 --> 00:07:45,110
waiting for Pandas now. And yeah, Pandas was installed and the process took around let's say 8 minutes.

84
00:07:45,150 --> 00:07:52,790
So I had to speed up the video and done. Yeah, that was successful.

85
00:07:52,790 --> 00:07:54,740
Finally verifying deploying done.

86
00:07:55,120 --> 00:07:58,370
You can go ahead and browse now to your website.

87
00:07:58,550 --> 00:08:04,420
Either you can type in the URL manually or do Heroku open and that you will open the browser for you.

88
00:08:04,760 --> 00:08:11,950
Yeah this is my website, go to plot.

89
00:08:12,100 --> 00:08:14,050
And yeah, the graph is there.

90
00:08:14,600 --> 00:08:15,620
That's about this lecture.

91
00:08:15,670 --> 00:08:16,880
I hope you enjoy it.

92
00:08:17,200 --> 00:08:20,780
I hope things are working for you as they did for me!

93
00:08:21,120 --> 00:08:23,860
If I don't then please ask me.

94
00:08:23,870 --> 00:08:26,030
Drop a question in the discussion area. And yeah.

95
00:08:26,240 --> 00:08:30,580
I hope you enjoying the course and I'll talk to you in the next lectures.

96
00:08:30,580 --> 00:08:30,850
Thanks!

