1
00:00:06,340 --> 00:00:11,350
Welcome back in this lecture we're going to go through an example solution for the exercise.

2
00:00:11,410 --> 00:00:15,220
Keep in mind there's lots of different ways you could approach this project as long as you get some

3
00:00:15,220 --> 00:00:17,240
similar result for your web application.

4
00:00:17,350 --> 00:00:18,380
You're fine.

5
00:00:18,400 --> 00:00:21,130
Let's shift to text editor and walk through our solution.

6
00:00:21,130 --> 00:00:30,190
All right let's begin by saying from flask import flask and then from flask import request then we're

7
00:00:30,190 --> 00:00:37,720
going to create our application by saying opposite with the flask and passen that built in name variable.

8
00:00:37,810 --> 00:00:42,290
And we have two views here one is for my main index page.

9
00:00:42,400 --> 00:00:48,580
So let's just start by saying app routes and this is just going to go to the next page just a single

10
00:00:48,580 --> 00:01:03,780
forward slash index and we're just going to return go to a puppy underscore named last name and see

11
00:01:03,780 --> 00:01:04,600
the result.

12
00:01:06,310 --> 00:01:10,170
And obviously you could freely say whatever you want here and let's make this into a better one.

13
00:01:11,090 --> 00:01:16,990
By using these little tags these page html tags the forward slash there and then at the very end.

14
00:01:17,330 --> 00:01:20,720
And one more forward slash H-1.

15
00:01:20,960 --> 00:01:23,130
Right so we have our home page.

16
00:01:23,250 --> 00:01:26,610
Now comes the more interesting page of the actual puppy light and page

17
00:01:30,210 --> 00:01:38,020
here are going to say forward slash puppy underscore name forward slash and then we're taking in a variable.

18
00:01:38,020 --> 00:01:42,540
So need to wrap it around this greater than and less than sign.

19
00:01:42,620 --> 00:01:48,200
And then here we're going to call this puppy Latin function and we're going to take in that name that's

20
00:01:48,200 --> 00:01:51,310
passed then and we're essentially going to manipulate it.

21
00:01:51,510 --> 00:01:56,030
And then we're going to return certain things depending on what the actual name is.

22
00:01:56,330 --> 00:02:02,450
So let's start by saying pulp name is equal to an empty string and then we're going to add onto the

23
00:02:02,450 --> 00:02:05,060
string or build up the string and then return it at the end.

24
00:02:05,820 --> 00:02:10,670
So if the last letter of our name.

25
00:02:10,690 --> 00:02:20,110
So it indexed negative 1 is equal to Y then that means I'm just going to remove that and then add in

26
00:02:20,200 --> 00:02:21,600
I f u l.

27
00:02:21,910 --> 00:02:29,560
So I won't say what name is equal to the name that you passed in all the way up to but not including

28
00:02:29,920 --> 00:02:31,640
index negative 1.

29
00:02:31,660 --> 00:02:36,850
And then I'm going to concatenate on I f u l then I will say.

30
00:02:36,850 --> 00:02:40,500
Else That means it doesn't end in a Y.

31
00:02:40,510 --> 00:02:47,320
So I just say put names equal to the name that's passed in concatenated with Y and then once I have

32
00:02:47,320 --> 00:02:50,760
my puppy name in puppy Latin I'm just going to return it.

33
00:02:51,310 --> 00:03:05,220
So I'll say H-1 your puppy Latin name is and then we're going to insert it with that format up name.

34
00:03:05,250 --> 00:03:05,580
All right.

35
00:03:05,640 --> 00:03:07,260
So that should be it.

36
00:03:07,290 --> 00:03:09,600
Again there's lots of different ways you can work out this logic.

37
00:03:09,600 --> 00:03:14,460
So if your logic is slightly different here but as long as getting the same result if it ends for y

38
00:03:14,460 --> 00:03:20,970
you add i f u l and if it does and the full y you add on y you're OK.

39
00:03:20,970 --> 00:03:28,970
Now let's say if name is equal to mean take her app and run it let's go and check.

40
00:03:28,980 --> 00:03:32,030
So we'll say Python basic that PI looks like it's running.

41
00:03:32,030 --> 00:03:36,270
So let's bring that up in our actual browser going to bring it down here.

42
00:03:36,560 --> 00:03:39,310
So it says Good Puppy names slash name and see the result.

43
00:03:39,350 --> 00:03:40,730
So let's do that.

44
00:03:40,850 --> 00:03:47,590
I'll say puppy underscore name and then ingoing type in rufous.

45
00:03:48,030 --> 00:03:55,060
Looks like my puppy name is Rufus C and then the next one we're going to say just go ahead and type

46
00:03:55,290 --> 00:03:56,470
something that already ends in Y.

47
00:03:56,480 --> 00:04:02,150
So Rufus C..

48
00:04:02,350 --> 00:04:02,960
There we go.

49
00:04:02,980 --> 00:04:04,020
Run it now.

50
00:04:04,120 --> 00:04:09,370
Rufus Hafele looks so good for you but hopefully you get the idea just the idea that offends and fly

51
00:04:09,430 --> 00:04:11,480
you replace that white with a fuel.

52
00:04:11,820 --> 00:04:12,360
OK.

53
00:04:12,550 --> 00:04:14,440
So that's all we need to be able to do.

54
00:04:14,470 --> 00:04:17,180
Go ahead and check out the solutions if you need more clarity.

55
00:04:17,200 --> 00:04:20,760
But if you have any questions always feel free to post the Q&amp;A forms.

56
00:04:20,770 --> 00:04:22,050
We'll see you at the next section.
